Posted in
Windows Powershell,
Windows Server |
No Comment | 1,546 views | 24/09/2013 10:31
There are some disk operations you can do in Windows Server 2012 with PowerShell:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
| # Getting Disk Signature
Get-Disk | ft FriendlyName, Signature
# Add Disk Signatures into Array
$Signatures = "4D53465420202020E55D0891031DB04CB1F2B507ED9FDC88","4D53465420202020E55D0891031DB04CB1F2B507ED9FDC89"
# Making Them Online
foreach ($Signature in $Signatures)
{
Get-Disk | Where {$_.Signature -eq $Signature} | Set-Disk -IsOffline $False
}
# Making Them Offline
foreach ($Signature in $Signatures)
{
Get-Disk | Where {$_.Signature -eq $Signature} | Set-Disk -IsOffline $True
} |
# Getting Disk Signature
Get-Disk | ft FriendlyName, Signature
# Add Disk Signatures into Array
$Signatures = "4D53465420202020E55D0891031DB04CB1F2B507ED9FDC88","4D53465420202020E55D0891031DB04CB1F2B507ED9FDC89"
# Making Them Online
foreach ($Signature in $Signatures)
{
Get-Disk | Where {$_.Signature -eq $Signature} | Set-Disk -IsOffline $False
}
# Making Them Offline
foreach ($Signature in $Signatures)
{
Get-Disk | Where {$_.Signature -eq $Signature} | Set-Disk -IsOffline $True
}
Get-Disk is not available in Windows Server 2008 R2, so you should go with WMI.