/build/static/layout/Breadcrumb_cap_w.png

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.



0 Comments   [ + ] Show comments

Answers (3)

Answer Summary:
Posted by: KevinG 11 months ago
Red Belt
1

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    

Posted by: Jim Russell 11 months ago
White Belt
0

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
Posted by: Jim Russell 11 months ago
White Belt
0

Great. Thanks!

Don't be a Stranger!

Sign up today to participate, stay informed, earn points and establish a reputation for yourself!

Sign up! or login

View more:

Share

 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ