I am trying to write my first script but am having some issues with powershell.
I am using the following code:
$Disk = Get-Disk | Where-Object {$_.Path -match "USBSTOR" -and $_.Size -gt 20Gb -and $_.Size -lt 200Gb -and -not $_.IsBoot }
I can't figure out why
PS C:\> echo $disk
Number Friendly Name OperationalStatus Total Size Partition Style
------ ------------- ----------------- ---------- ---------------
1 Imation IronKey Wkspace USB Device Online 59.63 GB MBR
and
PS C:\> write-host $disk
MSFT_Disk (ObjectId = "\\?\usbstor#disk&ven_imation&prod_ironk...)
It is more complicated by the following powershell script:
$Disk = Get-Disk | Where-Object {$_.Path -match "USBSTOR" -and $_.Size -gt 20Gb -and $_.Size -lt 200Gb -and -not $_.IsBoot }
$WIM = Get-PSDrive -PSProvider FileSystem | Where { Test-Path (join-path $_.Root "\sources\install.wim") }
echo $Disk
echo $WIM
Write-Host $WIM
Write-Host $Disk
and then change the order of the echo's and writes I get different outputs
can someone explain what is going on?