hi all,
aside from dot sourcing, is there some oter way to call a function inside an external file?
I know about . .\myfile.ps1, I also know about modules, but in my case, both these options aren't doing what I want.
The issue is that I need to force a script to be launched in the 64-bit system from a SCCM 32-bit client. I want to launch like this;
start-process "C:\Windows\sysnative\WindowsPowerShell\v1.0\powershell.exe" -arg...
using dot sourcing won't enforce the bitness.
thanks!
calling function in external file
Forum rules
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Re: calling function in external file
The version of PowerShell enforces the bitness. This has nothing to do with the script or function calls. Functions always run in the architecture calling them.
Only dot sourcing will work
Dot sourcing is not what you posted. That is just loafing from the current folder. In a call like this you should always use the full path
Dot sourcing only a file will never execute any function.
Only dot sourcing will work
Dot sourcing is not what you posted. That is just loafing from the current folder. In a call like this you should always use the full path
Dot sourcing only a file will never execute any function.
Re: calling function in external file
Well, looks like I badly explained my situation.
In SCCM, when you want to deploy something to a bunch of computers, you create a "package" that is sent to those computers. The package has a command line to execute something.
On the computers, there is an agent that receives those instructions and proceed with the required installation. Thanks to Microsoft, the SCCM client in question is 32-bit, so our scripts are launched in that bitness. Now, if I use the command line to start the process of PowerShell.exe from c:\windows\sysnative..., Windows will comply and launch the required script in 64-bit on a 64-bit computer.
We have an issue with this because some scripts require to be executed in the 64-bit system even when launched from the 32-bit SCCM client. My way of going around it is to have the main wrapper script call an external script by enforcing the 64-bit system.
I hope this makes more sense now.
thanks!
In SCCM, when you want to deploy something to a bunch of computers, you create a "package" that is sent to those computers. The package has a command line to execute something.
On the computers, there is an agent that receives those instructions and proceed with the required installation. Thanks to Microsoft, the SCCM client in question is 32-bit, so our scripts are launched in that bitness. Now, if I use the command line to start the process of PowerShell.exe from c:\windows\sysnative..., Windows will comply and launch the required script in 64-bit on a 64-bit computer.
We have an issue with this because some scripts require to be executed in the 64-bit system even when launched from the 32-bit SCCM client. My way of going around it is to have the main wrapper script call an external script by enforcing the 64-bit system.
I hope this makes more sense now.
thanks!
Re: calling function in external file
In other words;
I can easily start another script each time with that sysnative thing but that means I would have to create a script for each function and that is what I want to avoid.
any hint?
I can easily start another script each time with that sysnative thing but that means I would have to create a script for each function and that is what I want to avoid.
any hint?