Merge pull request #37 from MKellyCBSD/USBImagingToolCreator.ps1

Update to USBImagingToolCreator.ps1
This commit is contained in:
rbalsleyMSFT
2024-07-10 12:56:28 -07:00
committed by GitHub
+6 -3
View File
@@ -177,7 +177,10 @@ Function New-DeploymentUSB {
$var = $false $var = $false
} }
} until (($DriveSelected -le $Count -1 -or $last) -and $var) } until (($DriveSelected -le $Count -1 -or $last) -and $var)
if($DisableAutoPlay){
$DisableAutoPlayCurrentSetting = (Get-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers" -Name DisableAutoplay).DisableAutoplay
if($DisableAutoPlay -and $DisableAutoPlayCurrentSetting -ne 1){
writelog "Disable autoPlay current setting is $DisableAutoPlayCurrentSetting"
WriteLog "Setting the registry key to disable autoplay for all drives" WriteLog "Setting the registry key to disable autoplay for all drives"
Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers" -Name "DisableAutoplay" -Value 1 -Type DWORD Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers" -Name "DisableAutoplay" -Value 1 -Type DWORD
} }
@@ -196,8 +199,8 @@ Function New-DeploymentUSB {
} }
WriteLog "Setting the registry key to re-enable autoplay for all drives" WriteLog "Setting the registry key to re-enable autoplay for all drives"
if($DisableAutoPlay){ if($DisableAutoPlay){
Writelog "Enabling Autoplay" Writelog "Setting disable autoplay setting back to $DisableAutoPlayCurrentSetting"
Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers" -Name "DisableAutoplay" -Value 0 -Type DWORD Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers" -Name "DisableAutoplay" -Value $DisableAutoPlayCurrentSetting -Type DWORD
} }
Writelog "Completed!" Writelog "Completed!"
} }