forked from directorcia/Office365
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Intune-connect.ps1
53 lines (41 loc) · 1.73 KB
/
Intune-connect.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<# CIAOPS
Script provided as is. Use at own risk. No guarantees or warranty provided.
Description - Log into Microsoft Intune
Source - https://github.com/directorcia/Office365/blob/master/Intune-connect.ps1
Prerequisites = 1
1. Ensure Intune Graph module (Microsoft.Graph.Intune) is installed and updated
More scripts available by joining http://www.ciaopspatron.com
#>
## Variables
$systemmessagecolor = "cyan"
$processmessagecolor = "green"
$errormessagecolor = "red"
$warningmessagecolor = "yellow"
## If you have running scripts that don't have a certificate, run this command once to disable that level of security
## set-executionpolicy -executionpolicy bypass -scope currentuser -force
Clear-Host
write-host -foregroundcolor $systemmessagecolor "Script started`n"
if (Get-Module -ListAvailable -Name windowsautopilotintune) {
Write-Host -foregroundcolor $processmessagecolor "Window Autopilot module found"
}
else {
Write-Host -foregroundcolor $warningmessagecolor "[Warning] - Windows Autopilot module not found."
write-host -foregroundcolor $warningmessagecolor "Install this module if you want to use Windows Autopilot commands"
}
Try {
Import-Module Microsoft.Graph.Intune | Out-Null
}
catch {
Write-Host -ForegroundColor $errormessagecolor "[001] - Failed to import Intune module - ", $_.Exception.Message
exit 1
}
write-host -foregroundcolor $processmessagecolor "Intune module loaded"
try {
Connect-MSGraph | Out-Null
}
catch {
Write-Host -ForegroundColor $errormessagecolor "[002] - Failed to connect to Intune - ", $_.Exception.Message
exit 2
}
write-host -foregroundcolor $processmessagecolor "Now connected to Intune service`n"
write-host -foregroundcolor $systemmessagecolor "Script Finished`n"