Skip to content

Commit

Permalink
1.3.4
Browse files Browse the repository at this point in the history
  • Loading branch information
NickolajA committed Sep 2, 2022
1 parent bf16d3a commit ac8c83d
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 35 deletions.
20 changes: 13 additions & 7 deletions Private/New-IntuneWin32AppBody.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,16 @@ function New-IntuneWin32AppBody {
Author: Nickolaj Andersen
Contact: @NickolajA
Created: 2020-01-04
Updated: 2021-08-31
Updated: 2022-09-02
Version history:
1.0.0 - (2020-01-04) Function created
1.0.1 - (2020-01-27) Added support for RequirementRule parameter input
1.0.2 - (2020-09-20) Added support for Owner, Notes, InformationURL, PrivacyURL and CompanyPortalFeaturedApp parameter inputs
1.0.3 - (2021-08-31) Added AppVersion optional parameter
1.0.3 - (2022-09-02) minimumSupportedOperatingSystem property is replaced by minimumSupportedWindowsRelease
Fixed a bug where minimumFreeDiskSpaceInMB, minimumMemoryInMB, minimumNumberOfProcessors and minimumCpuSpeedInMHz
would never contain any value since they're not handled by this function (https://github.com/MSEndpointMgr/IntuneWin32App/issues/44)
#>
[CmdletBinding(SupportsShouldProcess = $true)]
param(
Expand Down Expand Up @@ -214,14 +217,13 @@ function New-IntuneWin32AppBody {
)
# Determine values for requirement rules
if ($PSBoundParameters["RequirementRule"]) {
# Define required requirement rules propertoes
$ApplicableArchitectures = $RequirementRule["applicableArchitectures"]
$MinimumSupportedOperatingSystem = $RequirementRule["minimumSupportedOperatingSystem"]
$MinimumSupportedWindowsRelease = $RequirementRule["minimumSupportedWindowsRelease"]
}
else {
$ApplicableArchitectures = "x64,x86"
$MinimumSupportedOperatingSystem = @{
"v10_1607" = $true
}
$MinimumSupportedWindowsRelease = "2H20"
}

switch ($PSCmdlet.ParameterSetName) {
Expand All @@ -246,7 +248,11 @@ function New-IntuneWin32AppBody {
"runAsAccount" = $InstallExperience
"deviceRestartBehavior" = $RestartBehavior
}
"minimumSupportedOperatingSystem" = $MinimumSupportedOperatingSystem
"minimumSupportedWindowsRelease" = $MinimumSupportedWindowsRelease
"minimumFreeDiskSpaceInMB" = if ($RequirementRule["minimumFreeDiskSpaceInMB"]) { $RequirementRule["minimumFreeDiskSpaceInMB"] } else { "" }
"minimumMemoryInMB" = if ($RequirementRule["minimumMemoryInMB"]) { $RequirementRule["minimumMemoryInMB"] } else { "" }
"minimumNumberOfProcessors" = if ($RequirementRule["minimumNumberOfProcessors"]) { $RequirementRule["minimumNumberOfProcessors"] } else { "" }
"minimumCpuSpeedInMHz" = if ($RequirementRule["minimumCpuSpeedInMHz"]) { $RequirementRule["minimumCpuSpeedInMHz"] } else { "" }
"msiInformation" = @{
"packageType" = $MSIInstallPurpose
"productCode" = $MSIProductCode
Expand Down Expand Up @@ -289,7 +295,7 @@ function New-IntuneWin32AppBody {
"runAsAccount" = $InstallExperience
"deviceRestartBehavior" = $RestartBehavior
}
"minimumSupportedOperatingSystem" = $MinimumSupportedOperatingSystem
"minimumSupportedWindowsRelease" = $MinimumSupportedWindowsRelease
"msiInformation" = $null
"publisher" = $Publisher
"runAs32bit" = $false
Expand Down
9 changes: 5 additions & 4 deletions Public/Add-IntuneWin32App.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ function Add-IntuneWin32App {
Author: Nickolaj Andersen
Contact: @NickolajA
Created: 2020-01-04
Updated: 2021-08-31
Updated: 2022-09-02
Version history:
1.0.0 - (2020-01-04) Function created
Expand All @@ -80,6 +80,7 @@ function Add-IntuneWin32App {
1.0.4 - (2021-04-01) Updated token expired message to a warning instead of verbose output
1.0.5 - (2021-08-31) Updated to use new authentication header
1.0.6 - (2021-08-31) Added AppVersion optional parameter
1.0.7 - (2022-09-02) Removed break command that would prevent the Win32 app body JSON output from being display in case an error occured
#>
[CmdletBinding(SupportsShouldProcess=$true, DefaultParameterSetName = "MSI")]
param(
Expand Down Expand Up @@ -363,8 +364,8 @@ function Add-IntuneWin32App {
Write-Verbose -Message "Attempting to create Win32 app using constructed body converted to JSON content"
$Win32MobileAppRequest = Invoke-IntuneGraphRequest -APIVersion "Beta" -Resource "mobileApps" -Method "POST" -Body ($Win32AppBody | ConvertTo-Json)
if ($Win32MobileAppRequest.'@odata.type' -notlike "#microsoft.graph.win32LobApp") {
Write-Warning -Message "Failed to create Win32 app using constructed body. Passing converted body as JSON to output."; break
Write-Output -InputObject ($Win32AppBody | ConvertTo-Json)
Write-Warning -Message "Failed to create Win32 app using constructed body. Passing converted body as JSON to output."
Write-Warning -Message ($Win32AppBody | ConvertTo-Json); break
}
else {
Write-Verbose -Message "Successfully created Win32 app with ID: $($Win32MobileAppRequest.id)"
Expand All @@ -373,7 +374,7 @@ function Add-IntuneWin32App {
Write-Verbose -Message "Attempting to create contentVersions resource for the Win32 app"
$Win32MobileAppContentVersionRequest = Invoke-IntuneGraphRequest -APIVersion "Beta" -Resource "mobileApps/$($Win32MobileAppRequest.id)/microsoft.graph.win32LobApp/contentVersions" -Method "POST" -Body "{}"
if ([string]::IsNullOrEmpty($Win32MobileAppContentVersionRequest.id)) {
Write-Warning -Message "Failed to create contentVersions resource for Win32 app"; break
Write-Warning -Message "Failed to create contentVersions resource for Win32 app"
}
else {
Write-Verbose -Message "Successfully created contentVersions resource with ID: $($Win32MobileAppContentVersionRequest.id)"
Expand Down
5 changes: 3 additions & 2 deletions Public/New-IntuneWin32AppDetectionRuleScript.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@ function New-IntuneWin32AppDetectionRuleScript {
Author: Nickolaj Andersen
Contact: @NickolajA
Created: 2020-09-17
Updated: 2021-08-31
Updated: 2022-09-02
Version history:
1.0.0 - (2020-09-17) Function created
1.0.1 - (2021-08-31) Fixed an issue when using a non-UTF encoded multi-line script file
1.0.2 - (2022-09-02) Fixed GitHub reported issue #41 (https://github.com/MSEndpointMgr/IntuneWin32App/issues/41)
#>
[CmdletBinding(SupportsShouldProcess = $true)]
param(
Expand All @@ -46,7 +47,7 @@ function New-IntuneWin32AppDetectionRuleScript {
# Detect if passed script file exists
if (Test-Path -Path $ScriptFile) {
# Convert script file contents to base64 string
$ScriptContent = [System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes([System.IO.File]::ReadAllBytes("$($ScriptFile)") -join [Environment]::NewLine))
$ScriptContent = [System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes((Get-Content -Path "$($ScriptFile)" -Raw -Encoding UTF8)))

# Construct detection rule ordered table
$DetectionRule = [ordered]@{
Expand Down
35 changes: 17 additions & 18 deletions Public/New-IntuneWin32AppRequirementRule.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ function New-IntuneWin32AppRequirementRule {
.PARAMETER Architecture
Specify the architecture as a requirement for the Win32 app.
.PARAMETER MinimumSupportedOperatingSystem
Specify the minimum supported operating system version as a requirement for the Win32 app.
.PARAMETER MinimumSupportedWindowsRelease
Specify the minimum supported Windows release version as a requirement for the Win32 app.
.PARAMETER MinimumFreeDiskSpaceInMB
Specify the minimum free disk space in MB as a requirement for the Win32 app.
Expand All @@ -28,12 +28,13 @@ function New-IntuneWin32AppRequirementRule {
Author: Nickolaj Andersen
Contact: @NickolajA
Created: 2020-01-27
Updated: 2021-08-31
Updated: 2022-09-02
Version history:
1.0.0 - (2020-01-27) Function created
1.0.1 - (2021-03-22) Added new minimum supported operating system versions to parameter validation
1.0.2 - (2021-08-31) Added new minimum supported operating system versions to parameter validation
1.0.3 - (2022-09-02) minimumSupportedOperatingSystem property is replaced by minimumSupportedWindowsRelease
#>
[CmdletBinding(SupportsShouldProcess = $true)]
param(
Expand All @@ -42,10 +43,10 @@ function New-IntuneWin32AppRequirementRule {
[ValidateSet("x64", "x86", "All")]
[string]$Architecture,

[parameter(Mandatory = $true, HelpMessage = "Specify the minimum supported operating system version as a requirement for the Win32 app.")]
[parameter(Mandatory = $true, HelpMessage = "Specify the minimum supported Windows release version as a requirement for the Win32 app.")]
[ValidateNotNullOrEmpty()]
[ValidateSet("1607", "1703", "1709", "1803", "1809", "1903", "1909", "2004", "20H2", "21H1")]
[string]$MinimumSupportedOperatingSystem,
[string]$MinimumSupportedWindowsRelease,

[parameter(Mandatory = $false, HelpMessage = "Specify the minimum free disk space in MB as a requirement for the Win32 app.")]
[ValidateNotNullOrEmpty()]
Expand Down Expand Up @@ -73,24 +74,22 @@ function New-IntuneWin32AppRequirementRule {

# Construct table for supported operating systems
$OperatingSystemTable = @{
"1607" = "v10_1607"
"1703" = "v10_1703"
"1709" = "v10_1709"
"1803" = "v10_1803"
"1809" = "v10_1809"
"1903" = "v10_1903"
"1909" = "v10_1909"
"2004" = "v10_2004"
"20H2" = "v10_2H20"
"21H1" = "v10_21H1"
"1607" = "1607"
"1703" = "1703"
"1709" = "1709"
"1803" = "1803"
"1809" = "1809"
"1903" = "1903"
"1909" = "1909"
"2004" = "2004"
"20H2" = "2H20"
"21H1" = "21H1"
}

# Construct ordered hash-table with least amount of required properties for default requirement rule
$RequirementRule = [ordered]@{
"applicableArchitectures" = $ArchitectureTable[$Architecture]
"minimumSupportedOperatingSystem" = @{
$OperatingSystemTable[$MinimumSupportedOperatingSystem] = $true
}
"minimumSupportedWindowsRelease" = $OperatingSystemTable[$MinimumSupportedWindowsRelease]
}

# Add additional requirement rule details if specified on command line
Expand Down
10 changes: 6 additions & 4 deletions Public/New-IntuneWin32AppRequirementRuleScript.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,13 @@ function New-IntuneWin32AppRequirementRuleScript {
Author: Nickolaj Andersen
Contact: @NickolajA
Created: 2020-04-29
Updated: 2020-08-31
Updated: 2022-09-02
Version history:
1.0.0 - (2020-04-29) Function created
1.0.1 - (2021-08-31) Fixed an issue when using a non-UTF encoded multi-line script file
1.0.2 - (2022-09-02) Fixed GitHub reported issue #41 (https://github.com/MSEndpointMgr/IntuneWin32App/issues/41)
Fixed issue with wrong variables used for the Version based part for #microsoft.graph.win32LobAppPowerShellScriptRequirement
#>
[CmdletBinding(SupportsShouldProcess = $true)]
param(
Expand Down Expand Up @@ -206,7 +208,7 @@ function New-IntuneWin32AppRequirementRuleScript {
$ScriptFileName = [System.IO.Path]::GetFileName("$($ScriptFile)")

# Convert script file contents to base64 string
$ScriptContent = [System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes([System.IO.File]::ReadAllBytes("$($ScriptFile)") -join [Environment]::NewLine))
$ScriptContent = [System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes((Get-Content -Path "$($ScriptFile)" -Raw -Encoding UTF8)))

switch ($PSCmdlet.ParameterSetName) {
"String" {
Expand Down Expand Up @@ -286,8 +288,8 @@ function New-IntuneWin32AppRequirementRuleScript {
# Construct ordered hash-table with least amount of required properties for default requirement rule
$RequirementRuleScript = [ordered]@{
"@odata.type" = "#microsoft.graph.win32LobAppPowerShellScriptRequirement"
"operator" = $IntegerComparisonOperator
"detectionValue" = $IntegerValue
"operator" = $VersionComparisonOperator
"detectionValue" = $VersionValue
"displayName" = $ScriptFileName
"enforceSignatureCheck" = $EnforceSignatureCheck
"runAs32Bit" = $RunAs32BitOn64System
Expand Down

0 comments on commit ac8c83d

Please sign in to comment.