search
Categories
Sponsors
VirtualMetric Hyper-V Monitoring, Hyper-V Reporting
Archive
Blogroll

Badges
MCSE
Community

Cozumpark Bilisim Portali
Posted in Windows Powershell, Windows Server | 2 Comments | 7,686 views | 24/09/2013 10:47

There are some disk operations you can do in Windows Server 2008 R2 with PowerShell:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# Getting Disk Signature
Get-WmiObject Win32_DiskDrive | ft Name, Signature, Index
 
# Add Disk Signatures into Array
$Signatures = "650992792","650992689"
 
# Making Them Online
foreach ($Signature in $Signatures)
{
	$Disk = Get-WmiObject Win32_DiskDrive | Where {$_.Signature -eq $Signature}
	$DiskID = $Disk.index
	$DiskPartScript = @"
select disk $DiskID
online disk noerr
"@
	$DiskPartScript | diskpart	
}
 
# Making Them Offline
foreach ($Signature in $Signatures)
{
	$Disk = Get-WmiObject Win32_DiskDrive | Where {$_.Signature -eq $Signature}
	$DiskID = $Disk.index
	$DiskPartScript = @"
select disk $DiskID
offline disk noerr
"@
	$DiskPartScript | diskpart	
}

Get-Disk is not available in Windows Server 2008 R2, so you should go with WMI.


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
}

Get-Disk is not available in Windows Server 2008 R2, so you should go with WMI.