Forum Discussion
cmautner
3 years agoPuritan
If you were doing it programmatically, here is the local Powershell Call… You can also invoke $diskpart to a remote computer as part of a script block in the Invoke-Command if you are quarterbacking from a centralized server
```$diskSerial = "XYZ123"
Get-Disk | Where-Object { $_.serialnumber -eq $diskSerial }
$guid = [GUID]::NewGuid()
$disknumber = $targetDisk.DiskNumber
$cmds = "`"SELECT DISK $disknumber`"",
"`"attributes disk clear readonly`"",
"`"UNIQUEID DISK ID=$guid`""
$scriptblock = [string]::Join(",", $cmds)
$diskpart = $ExecutionContext.InvokeCommand.NewScriptBlock("$scriptblock | DISKPART")
$DiskOpResult = Invoke-Expression ($diskpart.ToString())```