How can I pass the variable $(Kace_Dependency_Dir) to a PowerShell script?
I want to use PowerShell scripts without having to hard code the dependance directory all the time.
If I clone an online Kace script that runs a PowerShell script, I want it to access the new dependency directory without having to change the script ID within PowerShell.
Answers (3)
Was there a particular reason you need the CWD passed to PS?
In the SMA Scripting feature. You can use the "On Success" -> "Launch a Program"
Launch a program...
Directory: $(KACE_SYS_DIR)\WindowsPowerShell\v1.0
File: powershell.exe
Wait for completion (checked)
Parameters: -nologo -executionpolicy bypass -noprofile -file $(KACE_DEPENDENCY_DIR)\my_ps_script.ps1
Top Answer
Hi, thanks for replying.
I am using Launch a program using 64-bit PS. I work at a university and have run into a lot of Eng/CS apps that need 64-bit PS.
Directory: C:\Windows\sysnative\WindowsPowerShell\v1.0
File: powershell.exe
Parameters: -nologo -executionpolicy bypass -noprofile -nonInteractive -file "$(KACE_DEPENDENCY_DIR)\my_ps_script.ps1"
What I want to do is pass the dependency dir to PS to avoid having to hardcode the dir inside the PS script.
Is there a way for PS to get the $(KACE_DEPENDENCY_DIR)?
Comments:
-
Using the Launch a Program with the above options, the CWD (current working directory) sould be the value of $(KACE_DEPENDENCY_DIR).
In PS you can get the CWD or the PS script path that should also be the value of $(KACE_DEPENDENCY_DIR). - KevinG 11 months ago