Skip to content

Commit

Permalink
1.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
NickolajA committed Jan 29, 2023
1 parent 44f3a9a commit d773d4a
Show file tree
Hide file tree
Showing 9 changed files with 116 additions and 44 deletions.
19 changes: 12 additions & 7 deletions Private/Expand-IntuneWin32AppCompressedFile.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,24 @@ function Expand-IntuneWin32AppCompressedFile {
param(
[parameter(Mandatory = $true, HelpMessage = "Specify an existing local path to where the win32 app .intunewin file is located.")]
[ValidateNotNullOrEmpty()]
[ValidatePattern("^[A-Za-z]{1}:\\\w+\\\w+")]
[ValidateScript({
# Check if path contains any invalid characters
# Check if file name contains any invalid characters
if ((Split-Path -Path $_ -Leaf).IndexOfAny([IO.Path]::GetInvalidFileNameChars()) -ge 0) {
Write-Warning -Message "$(Split-Path -Path $_ -Leaf) contains invalid characters"; break
throw "File name '$(Split-Path -Path $_ -Leaf)' contains invalid characters"
}
else {
# Check if file extension is intunewin
if ([System.IO.Path]::GetExtension((Split-Path -Path $_ -Leaf)) -like ".intunewin") {
return $true
# Check if full path exist
if (Test-Path -Path $_) {
# Check if file extension is intunewin
if ([System.IO.Path]::GetExtension((Split-Path -Path $_ -Leaf)) -like ".intunewin") {
return $true
}
else {
throw "Given file name '$(Split-Path -Path $_ -Leaf)' contains an unsupported file extension. Supported extension is '.intunewin'"
}
}
else {
Write-Warning -Message "$(Split-Path -Path $_ -Leaf) contains unsupported file extension. Supported extension is '.intunewin'"; break
throw "File or folder does not exist"
}
}
})]
Expand Down
19 changes: 12 additions & 7 deletions Public/Add-IntuneWin32App.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -108,19 +108,24 @@ function Add-IntuneWin32App {
[parameter(Mandatory = $true, ParameterSetName = "MSI", HelpMessage = "Specify a local path to where the win32 app .intunewin file is located.")]
[parameter(Mandatory = $true, ParameterSetName = "EXE")]
[ValidateNotNullOrEmpty()]
[ValidatePattern('^[a-z]:\\(?:[^\\/:*?"<>|\r\n]+\\)*[^\\/:*?"<>|\r\n]*$')]
[ValidateScript({
# Check if path contains any invalid characters
# Check if file name contains any invalid characters
if ((Split-Path -Path $_ -Leaf).IndexOfAny([IO.Path]::GetInvalidFileNameChars()) -ge 0) {
Write-Warning -Message "$(Split-Path -Path $_ -Leaf) contains invalid characters"; break
throw "File name '$(Split-Path -Path $_ -Leaf)' contains invalid characters"
}
else {
# Check if file extension is intunewin
if ([System.IO.Path]::GetExtension((Split-Path -Path $_ -Leaf)) -like ".intunewin") {
return $true
# Check if full path exist
if (Test-Path -Path $_) {
# Check if file extension is intunewin
if ([System.IO.Path]::GetExtension((Split-Path -Path $_ -Leaf)) -like ".intunewin") {
return $true
}
else {
throw "Given file name '$(Split-Path -Path $_ -Leaf)' contains an unsupported file extension. Supported extension is '.intunewin'"
}
}
else {
Write-Warning -Message "$(Split-Path -Path $_ -Leaf) contains unsupported file extension. Supported extension is '.intunewin'"; break
throw "File or folder does not exist"
}
}
})]
Expand Down
19 changes: 12 additions & 7 deletions Public/Expand-IntuneWin32AppPackage.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,24 @@ function Expand-IntuneWin32AppPackage {
param(
[parameter(Mandatory = $true, HelpMessage = "Specify the full path of the locally available packaged Win32 application, e.g. 'C:\Temp\AppName.intunewin'.")]
[ValidateNotNullOrEmpty()]
[ValidatePattern('^[a-z]:\\(?:[^\\/:*?"<>|\r\n]+\\)*[^\\/:*?"<>|\r\n]*$')]
[ValidateScript({
# Check if path contains any invalid characters
# Check if file name contains any invalid characters
if ((Split-Path -Path $_ -Leaf).IndexOfAny([IO.Path]::GetInvalidFileNameChars()) -ge 0) {
Write-Warning -Message "$(Split-Path -Path $_ -Leaf) contains invalid characters"; break
throw "File name '$(Split-Path -Path $_ -Leaf)' contains invalid characters"
}
else {
# Check if file extension is intunewin
if ([System.IO.Path]::GetExtension((Split-Path -Path $_ -Leaf)) -like ".intunewin") {
return $true
# Check if full path exist
if (Test-Path -Path $_) {
# Check if file extension is intunewin
if ([System.IO.Path]::GetExtension((Split-Path -Path $_ -Leaf)) -like ".intunewin") {
return $true
}
else {
throw "Given file name '$(Split-Path -Path $_ -Leaf)' contains an unsupported file extension. Supported extension is '.intunewin'"
}
}
else {
Write-Warning -Message "$(Split-Path -Path $_ -Leaf) contains unsupported file extension. Supported extension is '.intunewin'"; break
throw "File or folder does not exist"
}
}
})]
Expand Down
19 changes: 12 additions & 7 deletions Public/Get-IntuneWin32AppMetaData.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,24 @@ function Get-IntuneWin32AppMetaData {
param(
[parameter(Mandatory = $true, HelpMessage = "Specify an existing local path to where the win32 app .intunewin file is located.")]
[ValidateNotNullOrEmpty()]
[ValidatePattern('^[a-z]:\\(?:[^\\/:*?"<>|\r\n]+\\)*[^\\/:*?"<>|\r\n]*$')]
[ValidateScript({
# Check if path contains any invalid characters
# Check if file name contains any invalid characters
if ((Split-Path -Path $_ -Leaf).IndexOfAny([IO.Path]::GetInvalidFileNameChars()) -ge 0) {
Write-Warning -Message "$(Split-Path -Path $_ -Leaf) contains invalid characters"; break
throw "File name '$(Split-Path -Path $_ -Leaf)' contains invalid characters"
}
else {
# Check if file extension is intunewin
if ([System.IO.Path]::GetExtension((Split-Path -Path $_ -Leaf)) -like ".intunewin") {
return $true
# Check if full path exist
if (Test-Path -Path $_) {
# Check if file extension is intunewin
if ([System.IO.Path]::GetExtension((Split-Path -Path $_ -Leaf)) -like ".intunewin") {
return $true
}
else {
throw "Given file name '$(Split-Path -Path $_ -Leaf)' contains an unsupported file extension. Supported extension is '.intunewin'"
}
}
else {
Write-Warning -Message "$(Split-Path -Path $_ -Leaf) contains unsupported file extension. Supported extension is '.intunewin'"; break
throw "File or folder does not exist"
}
}
})]
Expand Down
21 changes: 21 additions & 0 deletions Public/New-IntuneWin32AppDetectionRuleScript.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,27 @@ function New-IntuneWin32AppDetectionRuleScript {
param(
[parameter(Mandatory = $true, HelpMessage = "Specify the full path to the PowerShell detection script, e.g. 'C:\Scripts\Detection.ps1'.")]
[ValidateNotNullOrEmpty()]
[ValidateScript({
# Check if file name contains any invalid characters
if ((Split-Path -Path $_ -Leaf).IndexOfAny([IO.Path]::GetInvalidFileNameChars()) -ge 0) {
throw "File name '$(Split-Path -Path $_ -Leaf)' contains invalid characters"
}
else {
# Check if full path exist
if (Test-Path -Path $_) {
# Check if file extension is intunewin
if ([System.IO.Path]::GetExtension((Split-Path -Path $_ -Leaf)) -like ".ps1") {
return $true
}
else {
throw "Given file name '$(Split-Path -Path $_ -Leaf)' contains an unsupported file extension. Supported extension is '.ps1'"
}
}
else {
throw "File or folder does not exist"
}
}
})]
[string]$ScriptFile,

[parameter(Mandatory = $false, HelpMessage = "Specify if PowerShell script signature check should be enforced.")]
Expand Down
21 changes: 13 additions & 8 deletions Public/New-IntuneWin32AppIcon.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,25 @@ function New-IntuneWin32AppIcon {
param(
[parameter(Mandatory = $true, HelpMessage = "Specify an existing local path to where the PNG/JPG/JPEG image file is located.")]
[ValidateNotNullOrEmpty()]
[ValidatePattern('^[a-z]:\\(?:[^\\/:*?"<>|\r\n]+\\)*[^\\/:*?"<>|\r\n]*$')]
[ValidateScript({
# Check if path contains any invalid characters
# Check if file name contains any invalid characters
if ((Split-Path -Path $_ -Leaf).IndexOfAny([IO.Path]::GetInvalidFileNameChars()) -ge 0) {
Write-Warning -Message "$(Split-Path -Path $_ -Leaf) contains invalid characters"; break
throw "File name '$(Split-Path -Path $_ -Leaf)' contains invalid characters"
}
else {
# Check if file extension is PNG/JPG/JPEG
$FileExtension = [System.IO.Path]::GetExtension((Split-Path -Path $_ -Leaf))
if (($FileExtension -like ".png") -or ($FileExtension -like ".jpg") -or ($FileExtension -like ".jpeg")) {
return $true
# Check if full path exist
if (Test-Path -Path $_) {
# Check if file extension is jpg, png or jpeg
$FileExtension = [System.IO.Path]::GetExtension((Split-Path -Path $_ -Leaf))
if (($FileExtension -like ".png") -or ($FileExtension -like ".jpg") -or ($FileExtension -like ".jpeg")) {
return $true
}
else {
throw "Given file name '$(Split-Path -Path $_ -Leaf)' contains an unsupported file extension. Supported extensions are '.png', '.jpg' and '.jpeg'"
}
}
else {
Write-Warning -Message "$(Split-Path -Path $_ -Leaf) contains unsupported file extension. Supported extensions are '.png', '.jpg' and '.jpeg'"; break
throw "File or folder does not exist"
}
}
})]
Expand Down
21 changes: 21 additions & 0 deletions Public/New-IntuneWin32AppRequirementRuleScript.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,27 @@ function New-IntuneWin32AppRequirementRuleScript {
[parameter(Mandatory = $true, ParameterSetName = "Float")]
[parameter(Mandatory = $true, ParameterSetName = "Version")]
[ValidateNotNullOrEmpty()]
[ValidateScript({
# Check if file name contains any invalid characters
if ((Split-Path -Path $_ -Leaf).IndexOfAny([IO.Path]::GetInvalidFileNameChars()) -ge 0) {
throw "File name '$(Split-Path -Path $_ -Leaf)' contains invalid characters"
}
else {
# Check if full path exist
if (Test-Path -Path $_) {
# Check if file extension is intunewin
if ([System.IO.Path]::GetExtension((Split-Path -Path $_ -Leaf)) -like ".ps1") {
return $true
}
else {
throw "Given file name '$(Split-Path -Path $_ -Leaf)' contains an unsupported file extension. Supported extension is '.ps1'"
}
}
else {
throw "File or folder does not exist"
}
}
})]
[string]$ScriptFile,

[parameter(Mandatory = $true, ParameterSetName = "String", HelpMessage = "Specify to either run the script in the local system context or with signed in user context.")]
Expand Down
19 changes: 12 additions & 7 deletions Public/Update-IntuneWin32AppPackageFile.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,24 @@ function Update-IntuneWin32AppPackageFile {

[parameter(Mandatory = $true, HelpMessage = "Specify a local path to where the win32 app .intunewin file is located.")]
[ValidateNotNullOrEmpty()]
[ValidatePattern('^[a-z]:\\(?:[^\\/:*?"<>|\r\n]+\\)*[^\\/:*?"<>|\r\n]*$')]
[ValidateScript({
# Check if path contains any invalid characters
# Check if file name contains any invalid characters
if ((Split-Path -Path $_ -Leaf).IndexOfAny([IO.Path]::GetInvalidFileNameChars()) -ge 0) {
Write-Warning -Message "$(Split-Path -Path $_ -Leaf) contains invalid characters"; break
throw "File name '$(Split-Path -Path $_ -Leaf)' contains invalid characters"
}
else {
# Check if file extension is intunewin
if ([System.IO.Path]::GetExtension((Split-Path -Path $_ -Leaf)) -like ".intunewin") {
return $true
# Check if full path exist
if (Test-Path -Path $_) {
# Check if file extension is intunewin
if ([System.IO.Path]::GetExtension((Split-Path -Path $_ -Leaf)) -like ".intunewin") {
return $true
}
else {
throw "Given file name '$(Split-Path -Path $_ -Leaf)' contains an unsupported file extension. Supported extension is '.intunewin'"
}
}
else {
Write-Warning -Message "$(Split-Path -Path $_ -Leaf) contains unsupported file extension. Supported extension is '.intunewin'"; break
throw "File or folder does not exist"
}
}
})]
Expand Down
2 changes: 1 addition & 1 deletion ReleaseNotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## 1.4.0
- Properly fixed the issue with the public New-IntuneWin32AppRequirementRule and the private New-IntuneWin32AppBody functions to ensure the minimumFreeDiskSpaceInMB, MinimumMemoryInMB, MinimumNumberOfProcessors and minimumCpuSpeedInMHz objets are dynamically added to the request body, only if specificed on the command line with the New-IntuneWin32AppRequirementRule function.
- Added parameter AzCopyWindowStyle to Add-IntuneWin32App function, to support what's discussed in issue #64.
- Updated Add-IntuneWin32App, New-IntuneWin32AppIcon, Expand-IntuneWin32AppPackage, Get-IntuneWin32AppMetaData and Update-IntuneWin32AppPackageFile functions with an improved regex pattern for the FilePath parameter.
- Updated public Add-IntuneWin32App, New-IntuneWin32AppIcon, Expand-IntuneWin32AppPackage, Get-IntuneWin32AppMetaData, New-IntuneWin32AppDetectionRuleScript, New-IntuneWin32AppRequirementRuleScript, Update-IntuneWin32AppPackageFile and private Expand-IntuneWin32AppCompressedFile functions with improved file name validation which replaces the regex validation which was prohibiting usage of the module on non-Windows platforms, but also preventing accessing files on network shares.
- Added support for a new parameter named ScopeTagName for the Add-IntuneWin32App function. Scope Tags can now be added when creating the Win 32 application in Intune. This parameter supports multiple Scope Tags to be added at the same time.
- Improved error handling in Invoke-AzureADGraphRequest and Invoke-IntuneGraphRequest functions reported in issue #65.
- Added UnattendedInstall and UnattendedUninstall parameter switches to the Add-IntuneWin32App function. For MSI based setup installers, you can now specify whether to automatically append the install and/or uninstall command lines with the /quiet switch.
Expand Down

0 comments on commit d773d4a

Please sign in to comment.