xref: /spdk/test/vhost/windows/windows_scsi_compliance.ps1 (revision c84ecccca3d7ef56ee8a836767e6ca0afcb28419)
1 # Get the ID and security principal of the current user account
2 $myWindowsID=[System.Security.Principal.WindowsIdentity]::GetCurrent()
3 $myWindowsPrincipal=new-object System.Security.Principal.WindowsPrincipal($myWindowsID)
4 
5 # Get the security principal for the Administrator role
6 $adminRole=[System.Security.Principal.WindowsBuiltInRole]::Administrator
7 
8 # Check to see if we are currently running "as Administrator"
9 if ($myWindowsPrincipal.IsInRole($adminRole))
10    {
11    # We are running "as Administrator" - so change the title and background color to indicate this
12    $Host.UI.RawUI.WindowTitle = $myInvocation.MyCommand.Definition + "(Elevated)"
13    $Host.UI.RawUI.BackgroundColor = "DarkBlue"
14    clear-host
15    }
16 else
17    {
18    # We are not running "as Administrator" - so relaunch as administrator
19 
20    # Create a new process object that starts PowerShell
21    $newProcess = new-object System.Diagnostics.ProcessStartInfo "PowerShell";
22 
23    # Specify the current script path and name as a parameter
24    $newProcess.Arguments = $myInvocation.MyCommand.Definition;
25 
26    # Indicate that the process should be elevated
27    $newProcess.Verb = "runas";
28 
29    # Start the new process
30    [System.Diagnostics.Process]::Start($newProcess);
31 
32    # Exit from the current, unelevated, process
33    exit
34    }
35 # Run your code that needs to be elevated here
36 get-disk | Where-Object FriendlyName -NotMatch "QEMU" | Initialize-Disk -PartitionStyle MBR
37 Start-Sleep 2
38 get-disk | Where-Object FriendlyName -NotMatch "QEMU" | Clear-Disk -RemoveData -Confirm:$false
39 Start-Sleep 2
40 get-disk | Where-Object FriendlyName -NotMatch "QEMU" | Initialize-Disk -PartitionStyle MBR
41 Start-Sleep 2
42 
43 $disks = get-disk | Where-Object FriendlyName -NotMatch "QEMU"
44 Start-Sleep 2
45 foreach($disk in $disks)
46 {
47 
48     $phy_bs = $disk.PhysicalSectorSize
49     $model = $disk.model
50     $serial = $disk.SerialNumber
51 
52     $label = ""
53     $label += $model.Trim() + "_" + $serial + "_" + $phy_bs
54     $label = $label -replace " ", "_"
55     echo $label
56     start-sleep 2
57 
58     $part = New-Partition -DiskNumber $disk.Number -UseMaximumSize -AssignDriveLetter
59     echo $part.DriveLetter
60     start-sleep 2
61 
62     $vol = Format-Volume -DriveLetter $part.DriveLetter -FileSystem NTFS -Confirm:$false
63     echo $vol
64     start-sleep 2
65 
66     cd C:\SCSI
67     .\scsicompliancetest.exe \\.\$($vol.DriveLetter): -full | tee "C:\SCSI\WIN_SCSI_1_$label.log"
68     start-sleep 2
69     mv .\scsicompliance.log.wtl ".\WIN_SCSI_1_$label.wtl"
70     .\scsicompliance.exe /Device \\.\$($vol.DriveLetter): /Operation Test /Scenario Common | tee "C:\SCSI\WIN_SCSI_2_$label.log"
71     start-sleep 2
72     mv .\scsicompliance.wtl ".\WIN_SCSI_2_$label.wtl"
73     # Cleanup the drive
74     Clear-Disk -Number $disk.Number -RemoveData -Confirm:$false
75 }
76