Skip to content

Update device detection #47

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,7 @@ bin
*.nuspec
*.zip
localenv.ps1
!module.nuspec
!module.nuspec
*.sqlite
*.suo
*.gitignore
Binary file added .vs/Intune.USB.Creator/v16/.suo
Binary file not shown.
Binary file added .vs/slnx.sqlite
Binary file not shown.
19 changes: 2 additions & 17 deletions Invoke-Provision/Invoke-Provision.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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"}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -547,7 +533,6 @@ catch {
}
finally {
$sw.stop()
$USBDrive = Get-USBDeviceId
if ($exitEarly) {
$errorMsg = $null
}
Expand Down