ということでこんな感じで書いてみた。
PS> $username = "username" PS> $sPassword = ConvertTo-SecureString -String "password" -AsPlainText -Force PS> $credential = New-Object System.Management.Automation.PSCredential($username, $sPassword) PS> $hdd_list = Get-WmiObject -Class win32_logicaldisk -ComputerName "host-name" -Credential $credential PS> $msg = "" PS> foreach($hdd in $hdd_list) { PS> $driveLetter = $hdd.DeviceID -replace(":", "") PS> $freeSpace = [string] ([math]::round($hdd.FreeSpace / ([math]::pow(1024, 3)), 2)) PS> $msg = "Freespace of " + $driveLetter + " drive is " + $freeSpace + "(GB)." PS> } PS> $msg |
# 2015.04.09 1行目を追記。ご指摘ありがとうございます。
$username = "hogehoge"の記述が抜けているのはわざとですか?
返信削除記述漏れです(^^;
返信削除ご指摘ありがとうございます。