Skip to content

Commit 9ba4758

Browse files
New graph scripts
1 parent fc74dae commit 9ba4758

Some content is hidden

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

53 files changed

+2957
-1
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#Requires -Version 5.0
2+
#requires -Modules Microsoft.Graph.Identity.DirectoryManagement
3+
4+
<#
5+
.SYNOPSIS
6+
Checks groups of user or contact
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 Library script MS Graph\_LIB_\MGLibrary
20+
Requires Modules Microsoft.Graph.Identity.DirectoryManagement
21+
22+
.LINK
23+
https://github.com/scriptrunner/ActionPacks/tree/master/MS%20Graph/Contacts
24+
25+
.Parameter ContactId
26+
[sr-en] Identifier of the contact
27+
[sr-de] Kontakt-ID
28+
29+
.Parameter GroupIds
30+
[sr-en] Ids of the groups
31+
[sr-de] Gruppen-Identifier
32+
#>
33+
34+
param(
35+
[Parameter(Mandatory = $true)]
36+
[string]$ContactId,
37+
[string[]]$GroupIds
38+
)
39+
40+
Import-Module Microsoft.Graph.Identity.DirectoryManagement
41+
42+
try{
43+
ConnectMSGraph
44+
[hashtable]$cmdArgs = @{ErrorAction = 'Stop'
45+
'OrgContactId' = $ContactId
46+
'GroupIds' = $GroupIds
47+
'Confirm' = $false
48+
}
49+
$result = Confirm-MgContactMemberGroup @cmdArgs
50+
if($SRXEnv) {
51+
$SRXEnv.ResultMessage = $result
52+
}
53+
else{
54+
Write-Output $result
55+
}
56+
}
57+
catch{
58+
throw
59+
}
60+
finally{
61+
DisconnectMSGraph
62+
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#Requires -Version 5.0
2+
#requires -Modules Microsoft.Graph.Identity.DirectoryManagement
3+
4+
<#
5+
.SYNOPSIS
6+
Checks objects of user or contact
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 Library script MS Graph\_LIB_\MGLibrary
20+
Requires Modules Microsoft.Graph.Identity.DirectoryManagement
21+
22+
.LINK
23+
https://github.com/scriptrunner/ActionPacks/tree/master/MS%20Graph/Contacts
24+
25+
.Parameter ContactId
26+
[sr-en] Identifier of the contact
27+
[sr-de] Kontakt-ID
28+
29+
.Parameter Ids
30+
[sr-en] Ids of the objects
31+
[sr-de] Objekte-Identifier
32+
#>
33+
34+
param(
35+
[Parameter(Mandatory = $true)]
36+
[string]$ContactId,
37+
[string[]]$Ids
38+
)
39+
40+
Import-Module Microsoft.Graph.Identity.DirectoryManagement
41+
42+
try{
43+
ConnectMSGraph
44+
[hashtable]$cmdArgs = @{ErrorAction = 'Stop'
45+
'OrgContactId' = $ContactId
46+
'Ids' = $Ids
47+
'Confirm' = $false
48+
}
49+
$result = Confirm-MgContactMemberObject @cmdArgs
50+
if($SRXEnv) {
51+
$SRXEnv.ResultMessage = $result
52+
}
53+
else{
54+
Write-Output $result
55+
}
56+
}
57+
catch{
58+
throw
59+
}
60+
finally{
61+
DisconnectMSGraph
62+
}

MS Graph/Contacts/Get-MGCContact.ps1

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#Requires -Version 5.0
2+
#requires -Modules Microsoft.Graph.Identity.DirectoryManagement
3+
4+
<#
5+
.SYNOPSIS
6+
Returns entities from contacts
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 Library script MS Graph\_LIB_\MGLibrary
20+
Requires Modules Microsoft.Graph.Identity.DirectoryManagement
21+
22+
.LINK
23+
https://github.com/scriptrunner/ActionPacks/tree/master/MS%20Graph/Contacts
24+
25+
.Parameter ContactId
26+
[sr-en] Identifier of the contact
27+
[sr-de] Kontakt-ID
28+
29+
.Parameter Properties
30+
[sr-en] List of properties to expand. Use * for all properties
31+
[sr-de] Liste der zu anzuzeigenden Eigenschaften. Verwenden Sie * für alle Eigenschaften
32+
#>
33+
34+
param(
35+
[string]$ContactId,
36+
[ValidateSet('DisplayName','Id','CompanyName','DeletedDateTime','Department','GivenName','Surname','Mail','MailNickname','JobTitle','MemberOf','OnPremisesLastSyncDateTime','ProxyAddresses')]
37+
[string[]]$Properties = @('DisplayName','Id','GivenName','Surname','Mail')
38+
)
39+
40+
Import-Module Microsoft.Graph.Identity.DirectoryManagement
41+
42+
try{
43+
ConnectMSGraph
44+
[hashtable]$cmdArgs = @{ErrorAction = 'Stop'}
45+
if($PSBoundParameters.ContainsKey('ContactId') -eq $true){
46+
$cmdArgs.Add('OrgContactId',$ContactId)
47+
}
48+
$result = Get-MgContact @cmdArgs | Sort-Object DisplayName | Select-Object $Properties
49+
50+
if (Get-Command 'ConvertTo-ResultHtml' -ErrorAction Ignore) {
51+
ConvertTo-ResultHtml -Result $result
52+
}
53+
if($SRXEnv) {
54+
$SRXEnv.ResultMessage = $result
55+
}
56+
else{
57+
Write-Output $result
58+
}
59+
}
60+
catch{
61+
throw
62+
}
63+
finally{
64+
DisconnectMSGraph
65+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#Requires -Version 5.0
2+
#requires -Modules Microsoft.Graph.Identity.DirectoryManagement
3+
4+
<#
5+
.SYNOPSIS
6+
Returns contact's direct reports
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 Library script MS Graph\_LIB_\MGLibrary
20+
Requires Modules Microsoft.Graph.Identity.DirectoryManagement
21+
22+
.LINK
23+
https://github.com/scriptrunner/ActionPacks/tree/master/MS%20Graph/Contacts
24+
25+
.Parameter ContactId
26+
[sr-en] Identifier of the contact
27+
[sr-de] Kontakt-ID
28+
#>
29+
30+
param(
31+
[Parameter(Mandatory = $true)]
32+
[string]$ContactId
33+
)
34+
35+
Import-Module Microsoft.Graph.Identity.DirectoryManagement
36+
37+
try{
38+
ConnectMSGraph
39+
[hashtable]$cmdArgs = @{ErrorAction = 'Stop'
40+
'OrgContactId' = $ContactId
41+
}
42+
$result = Get-MgContactDirectReport @cmdArgs | Select-Object *
43+
44+
if($SRXEnv) {
45+
$SRXEnv.ResultMessage = $result
46+
}
47+
else{
48+
Write-Output $result
49+
}
50+
}
51+
catch{
52+
throw
53+
}
54+
finally{
55+
DisconnectMSGraph
56+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#Requires -Version 5.0
2+
#requires -Modules Microsoft.Graph.Identity.DirectoryManagement
3+
4+
<#
5+
.SYNOPSIS
6+
Returns user or contact that is this contact's manager
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 Library script MS Graph\_LIB_\MGLibrary
20+
Requires Modules Microsoft.Graph.Identity.DirectoryManagement
21+
22+
.LINK
23+
https://github.com/scriptrunner/ActionPacks/tree/master/MS%20Graph/Contacts
24+
25+
.Parameter ContactId
26+
[sr-en] Identifier of the contact
27+
[sr-de] Kontakt-ID
28+
#>
29+
30+
param(
31+
[Parameter(Mandatory = $true)]
32+
[string]$ContactId
33+
)
34+
35+
Import-Module Microsoft.Graph.Identity.DirectoryManagement
36+
37+
try{
38+
ConnectMSGraph
39+
[hashtable]$cmdArgs = @{ErrorAction = 'Stop'
40+
'OrgContactId' = $ContactId
41+
}
42+
$result = Get-MgContactManager @cmdArgs | Select-Object -ExpandProperty AdditionalProperties
43+
if($SRXEnv) {
44+
$SRXEnv.ResultMessage = $result
45+
}
46+
else{
47+
Write-Output $result
48+
}
49+
}
50+
catch{
51+
throw
52+
}
53+
finally{
54+
DisconnectMSGraph
55+
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#Requires -Version 5.0
2+
#requires -Modules Microsoft.Graph.Identity.DirectoryManagement
3+
4+
<#
5+
.SYNOPSIS
6+
Returns groups of user or contact
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 Library script MS Graph\_LIB_\MGLibrary
20+
Requires Modules Microsoft.Graph.Identity.DirectoryManagement
21+
22+
.LINK
23+
https://github.com/scriptrunner/ActionPacks/tree/master/MS%20Graph/Contacts
24+
25+
.Parameter ContactId
26+
[sr-en] Identifier of the contact
27+
[sr-de] Kontakt-ID
28+
29+
.Parameter SecurityEnabledOnly
30+
[sr-en] Member must be a user or service principal
31+
[sr-de] Mitglied muss ein Benutzer oder Service principal sein
32+
#>
33+
34+
param(
35+
[Parameter(Mandatory = $true)]
36+
[string]$ContactId,
37+
[switch]$SecurityEnabledOnly
38+
)
39+
40+
Import-Module Microsoft.Graph.Identity.DirectoryManagement
41+
42+
try{
43+
ConnectMSGraph
44+
[hashtable]$cmdArgs = @{ErrorAction = 'Stop'
45+
'OrgContactId' = $ContactId
46+
'SecurityEnabledOnly' = $SecurityEnabledOnly.IsPresent
47+
}
48+
$result = Get-MgContactMemberGroup @cmdArgs
49+
if($SRXEnv) {
50+
$SRXEnv.ResultMessage = $result
51+
}
52+
else{
53+
Write-Output $result
54+
}
55+
}
56+
catch{
57+
throw
58+
}
59+
finally{
60+
DisconnectMSGraph
61+
}

0 commit comments

Comments
 (0)