@@ -219,51 +219,38 @@ $ExportPath
219219
220220 if ($JSON -eq " " -or $JSON -eq $null ){
221221
222- write-host " No JSON specified, please specify valid JSON..." -f Red
222+ write-host " No JSON specified, please specify valid JSON..." -f Red
223223
224224 }
225225
226226 elseif (! $ExportPath ){
227227
228- write-host " No export path parameter set, please provide a path to export the file" -f Red
228+ write-host " No export path parameter set, please provide a path to export the file" -f Red
229229
230230 }
231231
232232 elseif (! (Test-Path $ExportPath )){
233233
234- write-host " $ExportPath doesn't exist, can't export JSON Data" -f Red
234+ write-host " $ExportPath doesn't exist, can't export JSON Data" -f Red
235235
236236 }
237237
238238 else {
239239
240- $JSON1 = ConvertTo-Json $JSON - Depth 5
240+ $JSON1 = ConvertTo-Json $JSON - Depth 5
241241
242- $JSON_Convert = $JSON1 | ConvertFrom-Json
242+ $JSON_Convert = $JSON1 | ConvertFrom-Json
243243
244- $displayName = $JSON_Convert.displayName
244+ $displayName = $JSON_Convert.displayName
245245
246- # Updating display name to follow file naming conventions - https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247%28v=vs.85%29.aspx
247- $DisplayName = $DisplayName -replace ' \<|\>|:|"|/|\\|\||\?|\*' , " _"
246+ # Updating display name to follow file naming conventions - https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247%28v=vs.85%29.aspx
247+ $DisplayName = $DisplayName -replace ' \<|\>|:|"|/|\\|\||\?|\*' , " _"
248248
249- $Properties = ($JSON_Convert | Get-Member | ? { $_.MemberType -eq " NoteProperty" }).Name
250-
251- $FileName_CSV = " $DisplayName " + " _" + $ (get-date -f dd- MM- yyyy- H- mm- ss) + " .csv"
252249 $FileName_JSON = " $DisplayName " + " _" + $ (get-date -f dd- MM- yyyy- H- mm- ss) + " .json"
253250
254- $Object = New-Object System.Object
255-
256- foreach ($Property in $Properties ){
257-
258- $Object | Add-Member - MemberType NoteProperty - Name $Property - Value $JSON_Convert .$Property
259-
260- }
261-
262251 write-host " Export Path:" " $ExportPath "
263252
264- $Object | Export-Csv - LiteralPath " $ExportPath \$FileName_CSV " - Delimiter " ," - NoTypeInformation - Append
265253 $JSON1 | Set-Content - LiteralPath " $ExportPath \$FileName_JSON "
266- write-host " CSV created in $ExportPath \$FileName_CSV ..." -f cyan
267254 write-host " JSON created in $ExportPath \$FileName_JSON ..." -f cyan
268255
269256 }
@@ -365,8 +352,8 @@ $ExportPath = Read-Host -Prompt "Please specify a path to export the policy data
365352
366353Write-Host
367354
368- $DCPs = Get-DeviceConfigurationPolicy
369-
355+ # Filtering out iOS and Windows Software Update Policies
356+ $DCPs = Get-DeviceConfigurationPolicy | Where-Object { ( $_ . ' @odata.type ' -ne " #microsoft.graph.iosUpdateConfiguration " ) -and ( $_ . ' @odata.type ' -ne " #microsoft.graph.windowsUpdateForBusinessConfiguration " ) }
370357foreach ($DCP in $DCPs ){
371358
372359write-host " Device Configuration Policy:" $DCP.displayName -f Yellow
0 commit comments