Skip to content

Commit 4a96b54

Browse files
Graph Users scripts reviewed
1 parent 7011a5d commit 4a96b54

File tree

85 files changed

+1671
-250
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+1671
-250
lines changed

MS Graph/Users/Get-MGUUser.ps1

+1-4
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
© ScriptRunner Software GmbH
1717
1818
.COMPONENT
19-
Requires Library script MS Graph\_LIB_\MGLibrary
2019
Requires Modules Microsoft.Graph.Users
2120
2221
.LINK
@@ -42,7 +41,6 @@ param(
4241
Import-Module Microsoft.Graph.Users
4342

4443
try{
45-
ConnectMSGraph
4644
[hashtable]$cmdArgs = @{ErrorAction = 'Stop'}
4745
if($PSBoundParameters.ContainsKey('UserId') -eq $true){
4846
$cmdArgs.Add('UserId',$UserId)
@@ -56,7 +54,7 @@ try{
5654
if (Get-Command 'ConvertTo-ResultHtml' -ErrorAction Ignore) {
5755
ConvertTo-ResultHtml -Result $result
5856
}
59-
if($SRXEnv) {
57+
if($null -ne $SRXEnv) {
6058
$SRXEnv.ResultMessage = $result
6159
}
6260
else{
@@ -67,5 +65,4 @@ catch{
6765
throw
6866
}
6967
finally{
70-
DisconnectMSGraph
7168
}

MS Graph/Users/Get-MGUUserCount.ps1

+1-4
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
© ScriptRunner Software GmbH
1717
1818
.COMPONENT
19-
Requires Library script MS Graph\_LIB_\MGLibrary
2019
Requires Modules Microsoft.Graph.Users
2120
2221
.LINK
@@ -29,11 +28,10 @@ param(
2928
Import-Module Microsoft.Graph.Users
3029

3130
try{
32-
ConnectMSGraph
3331
[hashtable]$cmdArgs = @{ErrorAction = 'Stop'}
3432
$result = Get-MgUserCount -ConsistencyLevel eventual @cmdArgs | Select-Object $Properties
3533

36-
if($SRXEnv) {
34+
if($null -ne $SRXEnv) {
3735
$SRXEnv.ResultMessage = $result
3836
}
3937
else{
@@ -44,5 +42,4 @@ catch{
4442
throw
4543
}
4644
finally{
47-
DisconnectMSGraph
4845
}

MS Graph/Users/Get-MGUUserCreatedObject.ps1

+1-4
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
© ScriptRunner Software GmbH
1717
1818
.COMPONENT
19-
Requires Library script MS Graph\_LIB_\MGLibrary
2019
Requires Modules Microsoft.Graph.Users
2120
2221
.LINK
@@ -35,14 +34,13 @@ param(
3534
Import-Module Microsoft.Graph.Users
3635

3736
try{
38-
ConnectMSGraph
3937
[hashtable]$cmdArgs = @{ErrorAction = 'Stop'
4038
'UserId'= $UserId
4139
'All' = $null
4240
}
4341
$result = Get-MgUserCreatedObject @cmdArgs | Select-Object *
4442

45-
if($SRXEnv) {
43+
if($null -ne $SRXEnv) {
4644
$SRXEnv.ResultMessage = $result
4745
}
4846
else{
@@ -53,5 +51,4 @@ catch{
5351
throw
5452
}
5553
finally{
56-
DisconnectMSGraph
5754
}

MS Graph/Users/Get-MGUUserDirectReportAsUser.ps1

+1-4
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
© ScriptRunner Software GmbH
1717
1818
.COMPONENT
19-
Requires Library script MS Graph\_LIB_\MGLibrary
2019
Requires Modules Microsoft.Graph.Users
2120
2221
.LINK
@@ -35,7 +34,6 @@ param(
3534
Import-Module Microsoft.Graph.Users
3635

3736
try{
38-
ConnectMSGraph
3937
[hashtable]$cmdArgs = @{ErrorAction = 'Stop'
4038
'UserId'= $UserId
4139
'All' = $null
@@ -45,7 +43,7 @@ try{
4543
if (Get-Command 'ConvertTo-ResultHtml' -ErrorAction Ignore) {
4644
ConvertTo-ResultHtml -Result $result
4745
}
48-
if($SRXEnv) {
46+
if($null -ne $SRXEnv) {
4947
$SRXEnv.ResultMessage = $result
5048
}
5149
else{
@@ -56,5 +54,4 @@ catch{
5654
throw
5755
}
5856
finally{
59-
DisconnectMSGraph
6057
}

MS Graph/Users/Get-MGUUserDirectReportCount.ps1

+1-4
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
© ScriptRunner Software GmbH
1717
1818
.COMPONENT
19-
Requires Library script MS Graph\_LIB_\MGLibrary
2019
Requires Modules Microsoft.Graph.Users
2120
2221
.LINK
@@ -35,14 +34,13 @@ param(
3534
Import-Module Microsoft.Graph.Users
3635

3736
try{
38-
ConnectMSGraph
3937
[hashtable]$cmdArgs = @{ErrorAction = 'Stop'
4038
'UserId'= $UserId
4139
'ConsistencyLevel' = 'eventual'
4240
}
4341
$result = Get-MgUserDirectReportCount @cmdArgs
4442

45-
if($SRXEnv) {
43+
if($null -ne $SRXEnv) {
4644
$SRXEnv.ResultMessage = $result
4745
}
4846
else{
@@ -53,5 +51,4 @@ catch{
5351
throw
5452
}
5553
finally{
56-
DisconnectMSGraph
5754
}

MS Graph/Users/Get-MGUUserExtension.ps1

+1-4
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
© ScriptRunner Software GmbH
1717
1818
.COMPONENT
19-
Requires Library script MS Graph\_LIB_\MGLibrary
2019
Requires Modules Microsoft.Graph.Users
2120
2221
.LINK
@@ -35,7 +34,6 @@ param(
3534
Import-Module Microsoft.Graph.Users
3635

3736
try{
38-
ConnectMSGraph
3937
[hashtable]$cmdArgs = @{ErrorAction = 'Stop'
4038
'UserId'= $UserId
4139
'All' = $null
@@ -45,7 +43,7 @@ try{
4543
if (Get-Command 'ConvertTo-ResultHtml' -ErrorAction Ignore) {
4644
ConvertTo-ResultHtml -Result $result
4745
}
48-
if($SRXEnv) {
46+
if($null -ne $SRXEnv) {
4947
$SRXEnv.ResultMessage = $result
5048
}
5149
else{
@@ -56,5 +54,4 @@ catch{
5654
throw
5755
}
5856
finally{
59-
DisconnectMSGraph
6057
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#Requires -Version 5.0
2+
#requires -Modules Microsoft.Graph.Users
3+
4+
<#
5+
.SYNOPSIS
6+
Returns a collection of the user's license details
7+
8+
.DESCRIPTION
9+
10+
.NOTES
11+
This PowerShell script was developed and optimized for ScriptRunner. The use of the scripts requires ScriptRunner.
12+
The customer or user is authorized to copy the script from the repository and use them in ScriptRunner.
13+
The terms of use for ScriptRunner do not apply to this script. In particular, ScriptRunner Software GmbH assumes no liability for the function,
14+
the use and the consequences of the use of this freely available script.
15+
PowerShell is a product of Microsoft Corporation. ScriptRunner is a product of ScriptRunner Software GmbH.
16+
© ScriptRunner Software GmbH
17+
18+
.COMPONENT
19+
Requires Modules Microsoft.Graph.Users
20+
21+
.LINK
22+
https://github.com/scriptrunner/ActionPacks/tree/master/MS%20Graph/Users
23+
24+
.Parameter UserId
25+
[sr-en] User identifier
26+
[sr-de] Benutzer ID
27+
#>
28+
29+
param(
30+
[Parameter(Mandatory = $true)]
31+
[string]$UserId
32+
)
33+
34+
Import-Module Microsoft.Graph.Users
35+
36+
try{
37+
[hashtable]$cmdArgs = @{ErrorAction = 'Stop'
38+
'UserId' = $UserId
39+
'All' = $null
40+
}
41+
$result = Get-MgUserLicenseDetail @cmdArgs | Select-Object *
42+
43+
if($null -ne $SRXEnv) {
44+
$SRXEnv.ResultMessage = $result
45+
}
46+
else{
47+
Write-Output $result
48+
}
49+
}
50+
catch{
51+
throw
52+
}
53+
finally{
54+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#Requires -Version 5.0
2+
#requires -Modules Microsoft.Graph.Users
3+
4+
<#
5+
.SYNOPSIS
6+
Returns settings for the primary mailbox of the user
7+
8+
.DESCRIPTION
9+
10+
.NOTES
11+
This PowerShell script was developed and optimized for ScriptRunner. The use of the scripts requires ScriptRunner.
12+
The customer or user is authorized to copy the script from the repository and use them in ScriptRunner.
13+
The terms of use for ScriptRunner do not apply to this script. In particular, ScriptRunner Software GmbH assumes no liability for the function,
14+
the use and the consequences of the use of this freely available script.
15+
PowerShell is a product of Microsoft Corporation. ScriptRunner is a product of ScriptRunner Software GmbH.
16+
© ScriptRunner Software GmbH
17+
18+
.COMPONENT
19+
Requires Modules Microsoft.Graph.Users
20+
21+
.LINK
22+
https://github.com/scriptrunner/ActionPacks/tree/master/MS%20Graph/Users
23+
24+
.Parameter UserId
25+
[sr-en] User identifier
26+
[sr-de] Benutzer ID
27+
#>
28+
29+
param(
30+
[Parameter(Mandatory = $true)]
31+
[string]$UserId
32+
)
33+
34+
Import-Module Microsoft.Graph.Users
35+
36+
try{
37+
[string[]]$Properties = @('DateFormat','TimeFormat','TimeZone','DelegateMeetingMessageDeliveryOptions','UserPurpose')
38+
[hashtable]$cmdArgs = @{ErrorAction = 'Stop'
39+
'UserId' = $UserId
40+
}
41+
$result = Get-MgUserMailboxSetting @cmdArgs | Select-Object $Properties
42+
43+
if($null -ne $SRXEnv) {
44+
$SRXEnv.ResultMessage = $result
45+
}
46+
else{
47+
Write-Output $result
48+
}
49+
}
50+
catch{
51+
throw
52+
}
53+
finally{
54+
}

MS Graph/Users/Get-MGUUserManager.ps1

+1-4
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
© ScriptRunner Software GmbH
1717
1818
.COMPONENT
19-
Requires Library script MS Graph\_LIB_\MGLibrary
2019
Requires Modules Microsoft.Graph.Users
2120
2221
.LINK
@@ -35,7 +34,6 @@ param(
3534
Import-Module Microsoft.Graph.Users
3635

3736
try{
38-
ConnectMSGraph
3937
[hashtable]$cmdArgs = @{ErrorAction = 'Stop'
4038
'UserId' = $UserId
4139
}
@@ -45,7 +43,7 @@ try{
4543
$result = Get-MgUser @cmdArgs | Select-Object @('DisplayName','Id','GivenName','Surname','Mail')
4644
}
4745

48-
if($SRXEnv) {
46+
if($null -ne $SRXEnv) {
4947
$SRXEnv.ResultMessage = $result
5048
}
5149
else{
@@ -56,5 +54,4 @@ catch{
5654
throw
5755
}
5856
finally{
59-
DisconnectMSGraph
6057
}

MS Graph/Users/Get-MGUUserMemberOf.ps1

+1-4
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
© ScriptRunner Software GmbH
1717
1818
.COMPONENT
19-
Requires Library script MS Graph\_LIB_\MGLibrary
2019
Requires Modules Microsoft.Graph.Users
2120
2221
.LINK
@@ -40,7 +39,6 @@ param(
4039
Import-Module Microsoft.Graph.Users
4140

4241
try{
43-
ConnectMSGraph
4442
[hashtable]$cmdArgs = @{ErrorAction = 'Stop'
4543
'UserId'= $UserId
4644
'All' = $null
@@ -72,7 +70,7 @@ try{
7270
if (Get-Command 'ConvertTo-ResultHtml' -ErrorAction Ignore) {
7371
ConvertTo-ResultHtml -Result $result
7472
}
75-
if($SRXEnv) {
73+
if($null -ne $SRXEnv) {
7674
$SRXEnv.ResultMessage = $result
7775
}
7876
else{
@@ -83,5 +81,4 @@ catch{
8381
throw
8482
}
8583
finally{
86-
DisconnectMSGraph
8784
}

MS Graph/Users/Get-MGUUserMemberOfCount.ps1

+1-4
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
© ScriptRunner Software GmbH
1717
1818
.COMPONENT
19-
Requires Library script MS Graph\_LIB_\MGLibrary
2019
Requires Modules Microsoft.Graph.Users
2120
2221
.LINK
@@ -40,7 +39,6 @@ param(
4039
Import-Module Microsoft.Graph.Users
4140

4241
try{
43-
ConnectMSGraph
4442
[hashtable]$cmdArgs = @{ErrorAction = 'Stop'
4543
'UserId'= $UserId
4644
'ConsistencyLevel' = 'eventual'
@@ -52,7 +50,7 @@ try{
5250
$mships = Get-MgUserMemberOfCount @cmdArgs | Select-Object *
5351
}
5452

55-
if($SRXEnv) {
53+
if($null -ne $SRXEnv) {
5654
$SRXEnv.ResultMessage = $mships
5755
}
5856
else{
@@ -63,5 +61,4 @@ catch{
6361
throw
6462
}
6563
finally{
66-
DisconnectMSGraph
6764
}

0 commit comments

Comments
 (0)