diff --git a/.gitignore b/.gitignore index af71fd2..47e60ae 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,7 @@ bin *.nuspec *.zip localenv.ps1 -!module.nuspec \ No newline at end of file +!module.nuspec +*.sqlite +*.suo +*.gitignore \ No newline at end of file diff --git a/.vs/Intune.USB.Creator/v16/.suo b/.vs/Intune.USB.Creator/v16/.suo new file mode 100644 index 0000000..caa40f8 Binary files /dev/null and b/.vs/Intune.USB.Creator/v16/.suo differ diff --git a/.vs/slnx.sqlite b/.vs/slnx.sqlite new file mode 100644 index 0000000..3a570b1 Binary files /dev/null and b/.vs/slnx.sqlite differ diff --git a/Invoke-Provision/Invoke-Provision.ps1 b/Invoke-Provision/Invoke-Provision.ps1 index 622a960..1b7fdca 100644 --- a/Invoke-Provision/Invoke-Provision.ps1 +++ b/Invoke-Provision/Invoke-Provision.ps1 @@ -145,21 +145,6 @@ exit throw $_ } } -function Get-USBDeviceId { - try { - $USBDrives = $drives | ?{ $_.BusType -eq "USB"} - if (@($USBDrives).count -eq 1) { - $USBDrive = $USBDrives[0].DeviceId - return $USBDrive - } - else { - throw "Error while getting DeviceId of USB Stick. No additional USB storage devices must be attached" - } - } - catch { - throw $_ - } -} function Get-SystemDeviceId { try { $dataDrives = $drives | ?{ $_.BusType -ne "USB"} @@ -464,7 +449,8 @@ try { #endregion #region Configure drive partitions Write-Host "`nConfiguring drive partitions.." -ForegroundColor Yellow - $drives = @(Get-PhysicalDisk) + $USBDrive = (Get-Partition -DriveLetter "$((Get-Item -Path $MyInvocation.MyCommand.Path).PSDrive)" | Get-Disk).Number + $drives = @(Get-PhysicalDisk | ? {$_.DeviceId -ne $USBDrive}) $targetDrive = Get-SystemDeviceId Set-DrivePartition -winPEDrive $usb.winPEDrive -targetDrive $targetDrive #endregion @@ -547,7 +533,6 @@ catch { } finally { $sw.stop() - $USBDrive = Get-USBDeviceId if ($exitEarly) { $errorMsg = $null }