Param (
[Parameter(Mandatory = $True)]
[String]
$fileName,
[Parameter(Mandatory = $True)]
$jsonContent,
[Parameter(Mandatory = $False)]
[Switch]
$debugWrite = $False,
[Parameter(Mandatory = $False)]
[String]
$ninjaAgentScriptingPath = "C:\ProgramData\NinjaRMMAgent\scripting\"
)
#
################################################################
#
# Functions
#
Function MainWrite {
CreateDropFile $fileName $jsonContent
}
#
#####
#
Function CreateDropFile ([String]$fileName, $content) {
if ($debugWrite) {Write-Host "fileName = " $fileName}
if ($debugWrite) {Write-Host "content = " $content}
$absPath = $ninjaAgentScriptingPath + $fileName
if ($debugWrite) {Write-Host "ninjaAgentScriptingPath = " $ninjaAgentScriptingPath}
if ($debugWrite) {Write-Host "absPath1 = " $absPath}
if (Test-Path -Path $absPath) {
if ($debugWrite) {Write-Host "File EXISTS, updating contents..."}
} else {
if ($debugWrite) {Write-Host "File does NOT exist, creating file & adding content..."}
New-Item $absPath -Type File # -Force
}
# either way, the contents get replaced...
$content | ConvertTo-Json | Set-Content -Path $absPath
} # end Function CreateDropFile...
#
#####
#
# Main()
#
MainWrite
#
#####