Move CD-Drive Letter in Lab

11:43 am Uncategorized
1..26 | % { Invoke-Command -ComputerName "LABNAME-C$($_)" -ScriptBlock {
Get-WmiObject -Class Win32_volume -Filter "DriveLetter = ""$(Get-Volume | ? { $_.DriveType -eq "CD-ROM" } | select -ExpandProperty DriveLetter | select -first 1):""" |Set-WmiInstance -Arguments @{DriveLetter='Z:'} }

1..26 creates an array 1 through 26.
% is short for foreach
$($_) uses each number from the 1..26 array
$(Get-Volume | ? { $_.DriveType -eq “CD-ROM” } | select -ExpandProperty DriveLetter | select -first 1) gets the first cd drive.

Leave a Comment

Your comment

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.