Skip to content
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

Fix token check and URL in Get-IntuneManagedDeviceBitLockerKeyPresence.ps1 #37

Open
wants to merge 126 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
126 commits
Select commit Hold shift + click to select a range
183e78b
Create Invoke-MSIntuneDriverUpdate.ps1
maurice-daly Dec 3, 2017
8d38932
Update Invoke-MSIntuneDriverUpdate.ps1
maurice-daly Dec 3, 2017
ab1973f
Update Invoke-MSIntuneDriverUpdate.ps1
maurice-daly Dec 3, 2017
0a6ac59
Update Invoke-MSIntuneDriverUpdate.ps1
maurice-daly Dec 4, 2017
137a9a0
Update Invoke-MSIntuneDriverUpdate.ps1
maurice-daly Dec 5, 2017
38ae031
Update Invoke-MSIntuneDriverUpdate.ps1
maurice-daly Dec 5, 2017
72c0c92
Update Invoke-MSIntuneDriverUpdate.ps1
maurice-daly Dec 5, 2017
36fc08c
1.0.0
NickolajA Mar 22, 2018
b9e33c0
Install-MSIntuneNDESServer.ps1 version 1.0.0
NickolajA Jun 21, 2018
ee5b7e3
Scripts added
NickolajA Nov 7, 2018
6454abd
Script moved
NickolajA Nov 7, 2018
86c8d87
Get-StoreAppInformation.ps1 version 1.0.1
NickolajA May 14, 2019
5afb7b1
Get-StoreAppInformation.ps1 version 1.0.1
NickolajA May 14, 2019
26284cd
Upload-WindowsAutopilotDeviceInfo.ps1 version 1.0.0
NickolajA Jun 3, 2019
2a7e713
Upload-WindowsAutopilotDeviceInfo.ps1 v. 1.0.0
NickolajA Jun 3, 2019
d17010f
1.0.0
NickolajA Oct 22, 2019
018ed5a
Version 1.0.0
NickolajA Oct 23, 2019
efd5db7
Version 1.0.1
NickolajA Oct 27, 2019
7aa46ed
Upload-WindowsAutopilotDeviceInfo version 1.1.0
NickolajA Oct 29, 2019
0e3e58f
Version 1.0.0
NickolajA Oct 31, 2019
fd3b8a0
Update-SCEPCertificate.ps1 version 1.0.0
NickolajA Dec 21, 2019
a1c1b0e
Detection script
NickolajA Dec 21, 2019
7e3f57b
SCEP certificate detection method
NickolajA Dec 21, 2019
85713e0
Update-SCEPCertificate.ps1 version 1.0.0
NickolajA Dec 21, 2019
e4a1aec
Create Readme.md
JankeSkanke Jan 2, 2020
5768c36
Update Readme.md
JankeSkanke Jan 2, 2020
3c59680
Enable-BitLockerEncryption.ps1 version 1.0.1
NickolajA Jan 3, 2020
6b17a89
Merge branch 'master' of https://github.com/SCConfigMgr/Intune
NickolajA Jan 3, 2020
44c31e7
Adding Monitor-IntuneAppleConnectors.ps1
JankeSkanke Jan 4, 2020
d780668
Enable-BitLockerEncryption.ps1 version 1.0.2
NickolajA Jan 15, 2020
704e3e7
placeholder
NickolajA Jan 16, 2020
592195b
IntuneWin32App version 1.0.0
NickolajA Jan 16, 2020
614386b
IntuneWin32App version 1.0.0
NickolajA Jan 16, 2020
8987c12
Readme
NickolajA Jan 17, 2020
a824637
Readme
NickolajA Jan 17, 2020
fc0a7c7
Readme
NickolajA Jan 17, 2020
6e87bbd
Readme
NickolajA Jan 17, 2020
c910312
Readme
NickolajA Jan 17, 2020
a6efe5d
Readme
NickolajA Jan 17, 2020
292a2e0
Readme
NickolajA Jan 17, 2020
440e7b7
IntuneWin32App version 1.0.1
NickolajA Jan 20, 2020
adb1f83
Release notes
NickolajA Jan 27, 2020
b5c6edc
Version 1.1.0
NickolajA Jan 27, 2020
50836a3
Version 1.2.2
NickolajA Jan 29, 2020
b603a3b
Visual C++ redistributables 1.0.0
NickolajA Feb 5, 2020
8493412
README.md
NickolajA Feb 10, 2020
7cfacac
Readme
NickolajA Feb 10, 2020
77ebd52
Update README.md
NickolajA Feb 10, 2020
5312e78
Updated description text
NickolajA Feb 10, 2020
8524f58
Readme
NickolajA Feb 10, 2020
3c2ddd9
Removed
NickolajA Mar 9, 2020
ab88496
Create placeholder.txt
JankeSkanke Mar 11, 2020
32b5e18
MDATP Configuration Settings for Intune
JankeSkanke Mar 11, 2020
ee715f6
Create placeholder.txt
JankeSkanke Mar 11, 2020
97d431e
Add files via upload
JankeSkanke Mar 11, 2020
6db9147
Add files via upload
JankeSkanke Mar 11, 2020
8d55967
Add files via upload
JankeSkanke Mar 11, 2020
252cbb7
Version 1.1.1
NickolajA Apr 22, 2020
882f5ae
Update-SCEPCertificate.ps1 version 1.0.1
NickolajA Apr 24, 2020
c2fb41a
Merge branch 'master' of https://github.com/SCConfigMgr/Intune
NickolajA Apr 24, 2020
541739c
1.2.0-RC
NickolajA Apr 30, 2020
cbd65f0
1.2.0-RC
NickolajA Apr 30, 2020
a5e7935
1.2.0-RC
NickolajA Apr 30, 2020
8ced8a8
1.2.0-RC
NickolajA May 3, 2020
d1c1c3c
Moved to separate repo
NickolajA May 20, 2020
505e9c4
Set-WindowsTimeZone.ps1 version 1.0.0
NickolajA May 20, 2020
ec81261
Set-WindowsTimeZone.ps1 version 1.0.1
NickolajA May 23, 2020
ac2fa05
Version 1.0.0
NickolajA Aug 13, 2020
5c76f7e
Merge branch 'master' of https://github.com/SCConfigMgr/Intune
NickolajA Aug 13, 2020
08cef70
Version 1.0.2
NickolajA Aug 13, 2020
a30c04a
Version 1.0.0
NickolajA Aug 13, 2020
75365c9
Version 1.0.0
NickolajA Aug 13, 2020
d01b1ff
Version 1.0.0
NickolajA Aug 13, 2020
d09a9d7
1.0.2
NickolajA Sep 11, 2020
8318ea9
1.0.0
NickolajA Sep 11, 2020
f4f7b58
1.0.1
NickolajA Sep 15, 2020
e7ec79f
1.0.2
NickolajA Sep 29, 2020
6b29e48
1.0.2
NickolajA Sep 29, 2020
f88141f
Create bitlockerremedy.ps1
JankeSkanke Oct 1, 2020
24ebfe7
1.0.0
NickolajA Oct 15, 2020
799f1f5
Merge branch 'master' of https://github.com/SCConfigMgr/Intune
NickolajA Oct 15, 2020
155c34d
1.0.0
NickolajA Dec 4, 2020
7fd1679
1.0.0
NickolajA Dec 4, 2020
0174665
1.0.1
NickolajA Dec 4, 2020
ff3639f
1.0.1
NickolajA Dec 4, 2020
106e4da
1.0.0
NickolajA Dec 4, 2020
e2cdf20
Removed
NickolajA Dec 4, 2020
e150313
1.0.0
NickolajA Dec 5, 2020
70cf674
1.0.0
NickolajA Dec 5, 2020
ae1ee09
1.0.3
NickolajA Dec 22, 2020
e9df0e2
1.0.3
NickolajA Dec 22, 2020
55a4529
1.2.3
NickolajA Jan 19, 2021
516a949
1.0.0
NickolajA Jan 19, 2021
69bb31c
1.0.0
NickolajA Jan 22, 2021
c310f6c
1.1.0
NickolajA Jan 28, 2021
ce2b894
1.0.0
NickolajA Feb 22, 2021
b948f43
Update Set-AutopilotDeviceGroupTag.ps1
GenerAhl Feb 22, 2021
9556a2c
Merge pull request #24 from GenerAhl/patch-1
NickolajA Feb 22, 2021
fa16f3c
Update README.md
NickolajA Mar 21, 2021
5594798
1.1.1
NickolajA Mar 24, 2021
bd615bf
Create Readme.md
JankeSkanke Mar 24, 2021
4dfb06d
Upload
JankeSkanke Mar 25, 2021
210fc8e
1.1.2
NickolajA Apr 2, 2021
15c696d
Merge branch 'master' of https://github.com/MSEndpointMgr/Intune
NickolajA Apr 2, 2021
7b9cee3
1.0.3
NickolajA Apr 7, 2021
c3f0506
1.0.3
NickolajA Apr 7, 2021
aaf03f6
1.0.3
NickolajA Apr 7, 2021
7767448
1.0.0
NickolajA Apr 11, 2021
c90efd7
Update Invoke-CustomInventory.ps1
JankeSkanke Apr 11, 2021
f6fd706
Merge branch 'master' of https://github.com/MSEndpointMgr/Intune
JankeSkanke Apr 11, 2021
aac590b
Delete Endpoint Manager Operational.workbook
JankeSkanke Apr 11, 2021
8fa7aa5
Delete Feature Update.workbook
JankeSkanke Apr 11, 2021
4ccccae
Delete Quality Update.workbook
JankeSkanke Apr 11, 2021
352132b
Add files via upload
JankeSkanke Apr 11, 2021
c894c00
Update
JankeSkanke Apr 12, 2021
563a3dd
Merge branch 'master' of https://github.com/MSEndpointMgr/Intune
JankeSkanke Apr 12, 2021
ddcd572
Fixed typo: ComputerCountry_s
JankeSkanke Apr 13, 2021
fa014e2
1.0.0
NickolajA May 6, 2021
8c52778
Merge branch 'master' of https://github.com/MSEndpointMgr/Intune
NickolajA May 6, 2021
899014f
Bugfixes
JankeSkanke Jun 9, 2021
bb96430
Merge branch 'master' of https://github.com/MSEndpointMgr/Intune
JankeSkanke Jun 17, 2021
2a22cdf
Create readme.md
JankeSkanke Sep 17, 2021
709e723
Create Invoke-DelayedTargetingGroup.ps1
JankeSkanke Sep 24, 2021
7a01efd
Create LICENSE
JankeSkanke Sep 24, 2021
5a1a9df
Merge pull request #35 from MSEndpointMgr/add-license-1
JankeSkanke Sep 24, 2021
68d7016
Fix $TokenExpierMins and $BitlockerRecoveryKeys
Rocketcandy Sep 24, 2021
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
243 changes: 243 additions & 0 deletions Apps/Get-IntuneiOSManagedAppAssignment.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,243 @@
<#
.SYNOPSIS
List all iOS managed apps assignment information.

.DESCRIPTION
List all iOS managed apps assignment information.

.PARAMETER TenantName
Specify the tenant name, e.g. domain.onmicrosoft.com.

.PARAMETER ApplicationID
Specify the Application ID of the app registration in Azure AD. By default, the script will attempt to use well known Microsoft Intune PowerShell app registration.

.PARAMETER PromptBehavior
Set the prompt behavior when acquiring a token.

.EXAMPLE
.\Get-IntuneiOSManagedAppAssignment.ps1 -TenantName 'name.onmicrosoft.com'

.NOTES
FileName: Get-IntuneiOSManagedAppAssignment.ps1
Author: Nickolaj Andersen
Contact: @NickolajA
Created: 2019-10-01
Updated: 2019-10-27

Version history:
1.0.0 - (2019-10-01) Script created
1.0.1 - (2019-10-27) Changed the filter for mobileApps resource to include managed apps too.

Required modules:
AzureAD (Install-Module -Name AzureAD)
PSIntuneAuth (Install-Module -Name PSIntuneAuth)
#>
[CmdletBinding(SupportsShouldProcess = $true)]
param(
[parameter(Mandatory = $true, HelpMessage = "Specify the tenant name, e.g. domain.onmicrosoft.com.")]
[ValidateNotNullOrEmpty()]
[string]$TenantName,

[parameter(Mandatory = $false, HelpMessage = "Specify the Application ID of the app registration in Azure AD. By default, the script will attempt to use well known Microsoft Intune PowerShell app registration.")]
[ValidateNotNullOrEmpty()]
[string]$ApplicationID = "d1ddf0e4-d672-4dae-b554-9d5bdfd93547",

[parameter(Mandatory=$false, HelpMessage="Set the prompt behavior when acquiring a token.")]
[ValidateNotNullOrEmpty()]
[ValidateSet("Auto", "Always", "Never", "RefreshSession")]
[string]$PromptBehavior = "Auto"
)
Begin {
# Determine if the PSIntuneAuth module needs to be installed
try {
Write-Verbose -Message "Attempting to locate PSIntuneAuth module"
$PSIntuneAuthModule = Get-InstalledModule -Name PSIntuneAuth -ErrorAction Stop -Verbose:$false
if ($PSIntuneAuthModule -ne $null) {
Write-Verbose -Message "Authentication module detected, checking for latest version"
$LatestModuleVersion = (Find-Module -Name PSIntuneAuth -ErrorAction Stop -Verbose:$false).Version
if ($LatestModuleVersion -gt $PSIntuneAuthModule.Version) {
Write-Verbose -Message "Latest version of PSIntuneAuth module is not installed, attempting to install: $($LatestModuleVersion.ToString())"
$UpdateModuleInvocation = Update-Module -Name PSIntuneAuth -Scope CurrentUser -Force -ErrorAction Stop -Confirm:$false -Verbose:$false
}
}
}
catch [System.Exception] {
Write-Warning -Message "Unable to detect PSIntuneAuth module, attempting to install from PSGallery"
try {
# Install NuGet package provider
$PackageProvider = Install-PackageProvider -Name NuGet -Force -Verbose:$false

# Install PSIntuneAuth module
Install-Module -Name PSIntuneAuth -Scope AllUsers -Force -ErrorAction Stop -Confirm:$false -Verbose:$false
Write-Verbose -Message "Successfully installed PSIntuneAuth"
}
catch [System.Exception] {
Write-Warning -Message "An error occurred while attempting to install PSIntuneAuth module. Error message: $($_.Exception.Message)" ; break
}
}

# Check if token has expired and if, request a new
Write-Verbose -Message "Checking for existing authentication token"
if ($Global:AuthToken -ne $null) {
$UTCDateTime = (Get-Date).ToUniversalTime()
$TokenExpireMins = ($Global:AuthToken.ExpiresOn.datetime - $UTCDateTime).Minutes
Write-Verbose -Message "Current authentication token expires in (minutes): $($TokenExpireMins)"
if ($TokenExpireMins -le 0) {
Write-Verbose -Message "Existing token found but has expired, requesting a new token"
$Global:AuthToken = Get-MSIntuneAuthToken -TenantName $TenantName -ClientID $ApplicationID -PromptBehavior $PromptBehavior
}
else {
if ($PromptBehavior -like "Always") {
Write-Verbose -Message "Existing authentication token has not expired but prompt behavior was set to always ask for authentication, requesting a new token"
$Global:AuthToken = Get-MSIntuneAuthToken -TenantName $TenantName -ClientID $ApplicationID -PromptBehavior $PromptBehavior
}
else {
Write-Verbose -Message "Existing authentication token has not expired, will not request a new token"
}
}
}
else {
Write-Verbose -Message "Authentication token does not exist, requesting a new token"
$Global:AuthToken = Get-MSIntuneAuthToken -TenantName $TenantName -ClientID $ApplicationID -PromptBehavior $PromptBehavior
}
}
Process {
# Functions
function Get-ErrorResponseBody {
param(
[parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[System.Exception]$Exception
)

# Read the error stream
$ErrorResponseStream = $Exception.Response.GetResponseStream()
$StreamReader = New-Object System.IO.StreamReader($ErrorResponseStream)
$StreamReader.BaseStream.Position = 0
$StreamReader.DiscardBufferedData()
$ResponseBody = $StreamReader.ReadToEnd()

# Handle return object
return $ResponseBody
}

function Invoke-IntuneGraphRequest {
param(
[parameter(Mandatory = $true, ParameterSetName = "Get")]
[parameter(ParameterSetName = "Patch")]
[ValidateNotNullOrEmpty()]
[string]$URI,

[parameter(Mandatory = $true, ParameterSetName = "Patch")]
[ValidateNotNullOrEmpty()]
[System.Object]$Body
)
try {
# Construct array list for return values
$ResponseList = New-Object -TypeName System.Collections.ArrayList

# Call Graph API and get JSON response
switch ($PSCmdlet.ParameterSetName) {
"Get" {
Write-Verbose -Message "Current Graph API call is using method: Get"
$GraphResponse = Invoke-RestMethod -Uri $URI -Headers $AuthToken -Method Get -ErrorAction Stop -Verbose:$false
if ($GraphResponse -ne $null) {
if ($GraphResponse.value -ne $null) {
foreach ($Response in $GraphResponse.value) {
$ResponseList.Add($Response) | Out-Null
}
}
else {
$ResponseList.Add($GraphResponse) | Out-Null
}
}
}
"Patch" {
Write-Verbose -Message "Current Graph API call is using method: Patch"
$GraphResponse = Invoke-RestMethod -Uri $URI -Headers $AuthToken -Method Patch -Body $Body -ContentType "application/json" -ErrorAction Stop -Verbose:$false
if ($GraphResponse -ne $null) {
foreach ($ResponseItem in $GraphResponse) {
$ResponseList.Add($ResponseItem) | Out-Null
}
}
else {
Write-Warning -Message "Response was null..."
}
}
}

return $ResponseList
}
catch [System.Exception] {
# Construct stream reader for reading the response body from API call
$ResponseBody = Get-ErrorResponseBody -Exception $_.Exception

# Handle response output and error message
Write-Output -InputObject "Response content:`n$ResponseBody"
Write-Warning -Message "Request to $($URI) failed with HTTP Status $($_.Exception.Response.StatusCode) and description: $($_.Exception.Response.StatusDescription)"
}
}

function Get-IntuneManagedApp {
# Construct Graph variables
$GraphVersion = "beta"
$GraphResource = "deviceAppManagement/mobileApps"
$GraphURI = "https://graph.microsoft.com/$($GraphVersion)/$($GraphResource)"

# Invoke Graph API resource call
$GraphResponse = Invoke-IntuneGraphRequest -URI $GraphURI

# Handle return objects from response
return $GraphResponse
}

function Get-IntuneManagedAppAssignment {
param(
[parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[string]$AppID
)
# Construct Graph variables
$GraphVersion = "beta"
$GraphResource = "deviceAppManagement/mobileApps/$($AppID)/assignments"
$GraphURI = "https://graph.microsoft.com/$($GraphVersion)/$($GraphResource)"

# Invoke Graph API resource call
$GraphResponse = Invoke-IntuneGraphRequest -URI $GraphURI

# Handle return objects from response
return $GraphResponse
}

# Retrieve all managed apps and filter on iOS
$ManagedApps = Get-IntuneManagedApp | Where-Object { $_.'@odata.type' -match "iosVppApp|iosStoreApp|managedIOSStoreApp" }

# Process each managed app
foreach ($ManagedApp in $ManagedApps) {
Write-Verbose -Message "Attempting to retrieve assignments for managed app: $($ManagedApp.displayName)"

# Retrieve assignments for current managed iOS app
$ManagedAppAssignments = Get-IntuneManagedAppAssignment -AppID $ManagedApp.id

# Continue if id property is not null, meaning that there's assignments for the current managed app
if ($ManagedAppAssignments.id -ne $null) {
# Process each assignment for the current managed app
foreach ($ManagedAppAssignment in $ManagedAppAssignments) {
# Construct a custom object for final output of script
$PSObject = [PSCustomObject]@{
AppName = $ManagedApp.displayName
AppType = $ManagedApp.'@odata.type'
AppID = $ManagedApp.id
AssignmentID = $ManagedAppAssignment.id
UninstallOnDeviceRemoval = $ManagedAppAssignments.settings.uninstallOnDeviceRemoval
}

# Handle final output
Write-Output -Inputobject $PSObject
}
}
else {
Write-Verbose -Message "Empty query returned for managed app assignments"
}
}
}
19 changes: 17 additions & 2 deletions Apps/Get-StoreAppInformation.ps1
Original file line number Diff line number Diff line change
@@ -1,32 +1,45 @@
<#
.SYNOPSIS
Search the iTunes or Google Play stores for the app links

.DESCRIPTION
This script can search for any app available in either iTunes or Google Play store

.PARAMETER Store
Specify which Store to search within

.PARAMETER AppName
Specify the app name to search for within the Store

.PARAMETER Limit
Limit search results to the specified number (only valid for iTunes Store)

.EXAMPLE
.\Get-StoreAppInformation.ps1 -Store iTunes -AppName "Microsoft Word" -Limit 1

.NOTES
Script name: Get-StoreAppInformation.ps1
FileName: Get-StoreAppInformation.ps1
Author: Nickolaj Andersen
Contact: @NickolajA
DateCreated: 2015-08-19
Created: 2015-08-19
Updated: 2019-05-14

Version history:
1.0.0 - (2015-08-19) Script created
1.0.1 - (2019-05-14) Added BundleId property returned from store search
#>
[CmdletBinding(SupportsShouldProcess=$true)]
param(
[parameter(Mandatory=$true, HelpMessage="Specify which Store to search within")]
[ValidateNotNullOrEmpty()]
[ValidateSet("iTunes","GooglePlay")]
[string]$Store,

[parameter(Mandatory=$true, HelpMessage="Specify the app name to search for within the Store")]
[ValidateNotNullOrEmpty()]
[ValidatePattern("^[A-Za-z\s]*$")]
[string]$AppName,

[parameter(Mandatory=$false, HelpMessage="Limit search results to the specified number (only valid for iTunes Store)")]
[ValidateNotNullOrEmpty()]
[string]$Limit = "1"
Expand Down Expand Up @@ -57,6 +70,7 @@ Process {
$PSObject = [PSCustomObject]@{
"AppName" = $Object.trackCensoredName
"StoreLink" = $Object.trackViewUrl
"BundleId" = $Object.bundleId
}
Write-Output -InputObject $PSObject
}
Expand All @@ -70,6 +84,7 @@ Process {
$PSObject = [PSCustomObject]@{
"AppName" = $Object.innerText
"StoreLink" = "https://play.google.com" + $Object.href
"BundleId" = ($Object.href).Split("=")[1]
}
Write-Output -InputObject $PSObject
}
Expand Down
Loading