microsoftgraph / powershell-intune-samples

This repository of PowerShell sample scripts show how to access Intune service resources. They demonstrate this by making HTTPS RESTful API requests to the Microsoft Graph API from PowerShell.
MIT License
1.36k stars 657 forks source link

Win32_Application_Add.ps1 Changing Source Path #213

Open MiamiFinsFan13 opened 2 years ago

MiamiFinsFan13 commented 2 years ago

I have the below code to upload a Win32 file

`import-module C:\Scripts\powershell-intune-samples-master\LOB_Application\Win32_Application_Add.ps1 -Force $SourceFile = "C:\Scripts\Intune Packaging\Packages\Printers\PrinterInstall.intunewin" $RegistryRule = New-DetectionRule -Registry -RegistryKeyPath "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Printers\BL-NS-GRN-GRN-FL1-P01" -RegistryDetectionType exists -check32BitRegOn64System False $ReturnCodes = Get-DefaultReturnCodes

$DetectionRule = @($RegistryRule)

Upload-Win32Lob -DisplayName -SourceFile "$SourceFile" -publisher "BrokerLink" -description "Printer 1 for Grand Falls" -detectionRules $DetectionRule -returnCodes $ReturnCodes -installCmdLine "PowerShell.exe -ExecutionPolicy Bypass -Command ""&" '.\PrinterInstall.ps1' -PrinterDriverName 'DriverName' -PrinterName ‘PrinterName' -PrinterPort 'xxx.xxx.xxx.xxx'""`

and it keeps outputting this error

PS C:\windows\system32> import-module C:\Scripts\powershell-intune-samples-master\LOB_Application\Win32_Application_Add.ps1 -Force $SourceFile = "C:\Scripts\Intune Packaging\Packages\Printers\PrinterInstall.intunewin" $RegistryRule = New-DetectionRule -Registry -RegistryKeyPath "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Printers\BL-NS-GRN-GRN-FL1-P01" -RegistryDetectionType exists -check32BitRegOn64System False $ReturnCodes = Get-DefaultReturnCodes

$DetectionRule = @($RegistryRule)

Upload-Win32Lob -DisplayName -SourceFile "$SourceFile" -publisher "BrokerLink" -description "Printer 1 for Grand Falls" -detectionRules $DetectionRule -returnCodes $ReturnCodes -installCmdLine "PowerShell.exe -ExecutionPolicy Bypass -Command ""&" '.\PrinterInstall.ps1' -PrinterDriverName 'Xerox Global PCL6' -PrinterName ‘BL-NS-GRN-GRN-FL1-P01' -PrinterPort '172.16.170.132'""

Source File 'C:\packages\package.intunewin' doesn't exist... ScriptHalted

I can't for the life of me figure out why it is changing the location of the Source File. Am I missing something here?

ukdocCT commented 2 years ago

line 1167 of the script has a hard code path and filename. Comment that out and it should work.