Initial commit of VMware.VCGChecker module
This commit is contained in:
17
Modules/VMware.VCGChecker/Save-VCGJsonFile.ps1
Normal file
17
Modules/VMware.VCGChecker/Save-VCGJsonFile.ps1
Normal file
@@ -0,0 +1,17 @@
|
||||
Function Save-VCGJsonFile{
|
||||
Param(
|
||||
[Parameter(Mandatory=$true)] $FileName,
|
||||
[Parameter(Mandatory=$true)] $Data,
|
||||
[Parameter(Mandatory=$true)] $Dir
|
||||
)
|
||||
$json = @()
|
||||
$Data | ForEach-Object { $json += $_.to_jsonobj()}
|
||||
|
||||
if (!(Test-Path $Dir)) {
|
||||
New-Item -Type directory -Confirm:$false -Path $Dir -Force |Out-Null
|
||||
}
|
||||
|
||||
$Path= $Dir + '\' + $FileName + '.json'
|
||||
info ("Saving data to " + $Path)
|
||||
ConvertTo-Json -Depth 10 -Compress $json | Out-File -encoding 'UTF8' -FilePath $Path
|
||||
}
|
||||
Reference in New Issue
Block a user