-
Notifications
You must be signed in to change notification settings - Fork 18
/
get-all-skype-for-business.policies.ps1
64 lines (56 loc) · 1.99 KB
/
get-all-skype-for-business.policies.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
54
55
56
57
58
59
60
61
62
63
64
<#
----------------------------------------------------
get-all-skype-for-business-policies.ps1
PowerShell Script to get all SFB policies
in Office 365 for further use in Excel
atwork.at, Martina Grom, 7/10/2016
----------------------------------------------------
#>
# Connect to your tenant first before running this script!
$separator = ","
$ignorefields = "XsAnyElements,XsAnyAttributes,PSComputerName,RunspaceId,PSShowComputerName,Element,ScopeClass,Anchor,Identity,TypedIdentity"
# get all policies first
$policies = Get-CsConferencingPolicy | select Identity
function GetHeader ([string]$policy, $properties) {
$p = "`"Identity`"$separator"
$properties.PSObject.Properties | foreach-object {
$propname = $_.Name.Tostring()
if ($ignorefields -notmatch $propname) {
$p += "`"$propname`"$separator"
}
}
$p += [Environment]::NewLine
return $p
}
function GetProperties ([string]$policy, $properties) {
$p = "`"$policy`"$separator"
$properties.PSObject.Properties | foreach-object {
$propname = $_.Name.Tostring()
$propvalue = $_.Value
if ($ignorefields -notmatch $propname) {
if ($propvalue -and $propvalue.Tostring().StartsWith("<")) {
$propvalue ="`"[XML]`""
}
$p += "`"$propvalue`"$separator"
}
}
$p += [Environment]::NewLine
return $p
}
$out = ''
$i = 0
Foreach ($policy in $policies) {
$i ++
Write-Output $policy.Identity
# read all properties per policy
$properties = Get-CsConferencingPolicy -Identity $policy.Identity
if ($i -eq 1) {
# create the header only once
$out += GetHeader $policy.Identity $properties
}
# read the properties and values
$out += GetProperties $policy.Identity $properties
}
Out-File .\skypepolicies.csv -inputObject $out
Write-Host "Done, check $out and use Excel with Data filter for finding the desired policy."
# end.