File not creating

Hi team,

I am using below Script to achieve my task and below script has been verified through fixlet debugger but still it is not creating txt files. Before this my script was getting failed on (waithidden { pathname of file ((it as string) of value “Path” of key “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell” of native registry) } -ExecutionPolicy Bypass -File powershell.ps1) then i had added extra curly brackets after this that issue sorted out but now i am facing issue in output.txt and error.txt file creation.

Kindly help me in this regards.

// Enter your action script here

action parameter query “Error_Folder” with description “Please enter the Error Folder Name” with default value ""
action parameter query “user_name” with description “Please enter the AD username to create” with default value ""
action parameter query “Identity” with description “Please enter the AD Username for Password reset” with default value ""
action parameter query “password” with description “Please enter the new password for AD user” with default value ""
action parameter query “username” with description “Please enter the AD username to enable” with default value “”

// Disable wow64 redirection on x64 OSes
action uses wow64 redirection {not x64 of operating system}

folder create {parameter “Error_Folder”}

// CREATEFILE
createfile until END_OF_FILE
//# REPLACE THE FOLLOWING WITH THE SCRIPT YOU WANT TO RUN ON THE ENDPOINT
New-ADUser -name {{parameter “user_name”}
Set-ADAccountPassword -Identity {{parameter “Identity”} -Reset -NewPassword (ConvertTo-SecureString -AsPlainText {{parameter “password”} -Force)
Enable-ADAccount -Identity {{parameter “username”}
$? > {{parameter “Error_Folder”}\output.txt
$Error > {{parameter “Error_Folder”}\error.txt

END_OF_FILE

delete powershell.ps1
move __createfile powershell.ps1
waithidden { pathname of file ((it as string) of value “Path” of key “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell” of native registry) } -ExecutionPolicy Bypass -File powershell.ps1

if {{exists file “output.txt” whose (line of it as string contains “False”) of folder (parameter “Error_Folder”)}
Exit 100
endif

Any relevance which you want to evaluate in action script should not be covered with double {{

I dont see any issue with your script other than double {{, even with double curly bracket file should be created with same value like {{parameter “Error_Folder”}

I have corrected your script & removed double curly bracket & was able to create file -

// Enter your action script here

action parameter query "Error_Folder" with description "Please enter the Error Folder Name" with default value ""
action parameter query "user_name" with description "Please enter the AD username to create" with default value ""
action parameter query "Identity" with description "Please enter the AD Username for Password reset" with default value ""
action parameter query "password" with description "Please enter the new password for AD user" with default value ""
action parameter query "username" with description "Please enter the AD username to enable" with default value ""

// Disable wow64 redirection on x64 OSes
action uses wow64 redirection {not x64 of operating system}

folder create {parameter "Error_Folder"}

// CREATEFILE
createfile until END_OF_FILE
//# REPLACE THE FOLLOWING WITH THE SCRIPT YOU WANT TO RUN ON THE ENDPOINT
New-ADUser -name {parameter "user_name"}
Set-ADAccountPassword -Identity {parameter "Identity"} -Reset -NewPassword (ConvertTo-SecureString -AsPlainText {parameter "password"} -Force)
Enable-ADAccount -Identity {parameter "username"}
$? > {parameter "Error_Folder"}\output.txt
$Error > {parameter "Error_Folder"}\error.txt

END_OF_FILE

delete powershell.ps1
move __createfile powershell.ps1

Above statement will also not work because of double curly bracket.

Below is the final output of file - based on the parameter which I passed.
//# REPLACE THE FOLLOWING WITH THE SCRIPT YOU WANT TO RUN ON THE ENDPOINT
New-ADUser -name ADUser
Set-ADAccountPassword -Identity Passwd -Reset -NewPassword (ConvertTo-SecureString -AsPlainText NewPass -Force)
Enable-ADAccount -Identity ADUserName
$? > C:\Temp\ram\output.txt
$Error > C:\Temp\ram\error.txt

if you are still seeing failure, please post action logs for this script execution, will see.

And for powershell execution, if you are not trying to run it on Win2008, you can simply type below-

waithidden {pathname of regapp "powershell.exe"} -ExecutionPolicy Bypass -File powershell.ps1

OR you can also do something like

if {exists regapp "powershell.exe"}
waithidden {pathname of regapp "powershell.exe"} -ExecutionPolicy Bypass -File powershell.ps1
else
{ pathname of file ((it as string) of value “Path” of key “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell” of native registry) } -ExecutionPolicy Bypass -File powershell.ps1
endif