Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

gwmi win32_volume value piped to variable

$
0
0

I'm in need of pulling the single volume name (with largest freespace over 40gb and label name starting with "CBC") remotely for the purpose of piping the value in another Powershell Exchange command. I have it correctly done below, but there seems to be additional empty space lines that seem to appear when I execute the $output variable below. When i pipe it into the Exchange command, there can not be any empty spaces, or empty lines or it will fail. It needs to just be the volume name, with no additional characters or spaces. Exchange powershell command i'll pipe it is the last line below. Thank you

$disk = gwmi win32_volume -ComputerName server216 | Select-Object label,freespace | Where-Object {$_.freespace -gt "42949672960"} | Where-Object {$_.label -match "CBC"} | sort freespace -Descending | select -First 1  

$output = ($disk | Format-Table label -HideTableHeaders | Out-String)

$output

New-moverequest “Doe, John” –targetdatabase “$($output)” –baditemlimit 25 –acceptlargedataloss –mrsserver "server983"

Viewing all articles
Browse latest Browse all 6937

Trending Articles