Skip to content

Commit

Permalink
first implementation #51
Browse files Browse the repository at this point in the history
  • Loading branch information
Wojciech Napierała committed Apr 8, 2019
1 parent 5989fd1 commit 5f4bb63
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion Find-TaskServiceUser.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ DONATION: If you want to support my work https://www.paypal.com/cgi-bin/webscr?c
[parameter(Mandatory = $false, HelpMessage = 'Enter path to export file.')]
[string]$Exportpath = [Environment]::GetFolderPath("MyDocuments") + "\Find-TaskServiceUser.XML",

[parameter(Mandatory = $false, HelpMessage = 'Enable exporting to JSON file.')]
[switch]$ExportJSON,

[parameter(Mandatory = $false, HelpMessage = 'Enter path to export JSON file.')]
[string]$ExportJSONpath = [Environment]::GetFolderPath("MyDocuments") + "\Find-TaskServiceUser.json",

[parameter(Mandatory = $false, HelpMessage = 'Switch to enable logging.')]
[switch]$Log,

Expand Down Expand Up @@ -222,7 +228,7 @@ DONATION: If you want to support my work https://www.paypal.com/cgi-bin/webscr?c
$services_count = $s
$tasks_count = $t
}
if ($Export) {
if ($Export -or $ExportJSON) {
Write-Verbose -Message "Building objects with all results"
if ($tasks) {
$tasks_all += $tasks
Expand Down Expand Up @@ -254,5 +260,13 @@ DONATION: If you want to support my work https://www.paypal.com/cgi-bin/webscr?c
#Add-Content -LiteralPath $Exportpath -Value $export_data -PassThru
Export-Clixml -LiteralPath $Exportpath -InputObject $export_data
}
if ($ExportJSON) {
Write-Information -MessageData "Export File: $($Exportjsonpath)" -InformationAction Continue
Write-Information -MessageData "Export File: You can import file using 'Import-Clixml `"$($Exportjsonpath)`"'" -InformationAction Continue
$task_all_unique = $tasks_all | Sort-Object taskname -Unique
$services_all_unique = $services_all | Sort-Object name -Unique
$export_data = @{"Tasks" = $task_all_unique; "Services" = $services_all }
$export_data | ConvertTo-Json | out-file $Exportjsonpath
}
} # end END block
} # end Find-TaskServiceUser function

0 comments on commit 5f4bb63

Please sign in to comment.