Menu

[ea00bd]: / util-dropFiles / CreateDropFile.ps1  Maximize  Restore  History

Download this file

48 lines (47 with data), 1.2 kB

 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
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
#
#####
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.