2009-12-02から1日間の記事一覧

DirectoryServices.DirectoryEntry で dispose できない罠

powershellの話。(ver1.0) 確認ロジック $target = New-Object DirectoryServices.DirectoryEntry( 'LDAP://rootDSE' ) if ( !($target -is [IDisposable]) ) { return; } $target.Dipose(); ちなみに GetType もできないし。 なんかのラッパーなのかと思う…

powershellの落とし穴

function test() { "aaaaa"; Write-Host "bbbbb"; Write-Output "ccccc"; return 100; } cls; $result = test; # output # bbbbb $result.Length; # output # 3 $result[0]; # output # aaaaa $result[1]; # output # ccccc $result[2]; # output # 100 retu…

PowershellでActiveDirectoryオブジェクトの属性を変更する。

絶対値が取れるのが前提。エラー処理とかないよ。 $targetAccountName = ""; $root = New-Object DirectoryServices.DirectoryEntry( 'LDAP://rootDSE' ) $dn = $root.defaultNamingContext.Value; $entry = New-Object DirectoryServices.DirectoryEntry( "…