I found something else
Here is execution policy on client :
Scope ExecutionPolicy
----- ---------------
MachinePolicy Unrestricted
UserPolicy Unrestricted
Process Undefined
CurrentUser Unrestricted
LocalMachine Unrestricted
With that if i launch .exe or .ps1 file it do not work. Same error "nom de répertoire non valide"
On same computer with the same standard user if i launch from powershell_ise my ps1 file with :
powershell.exe -file "T:\blocage internet.Export.ps1"
All working as expected.
Powershell command not work when compiled
Forum rules
DO NOT POST LICENSE NUMBERS, ACTIVATION KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.
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 LICENSE NUMBERS, ACTIVATION KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
-
- Posts: 20
- Last visit: Thu Mar 09, 2023 4:36 am
- Has voted: 1 time
-
- Posts: 20
- Last visit: Thu Mar 09, 2023 4:36 am
- Has voted: 1 time
Re: Powershell command not work when compiled
I found solution !!!!
i just have to add -WorkingDirectory to my command !
Code: Select all
Start-Process -FilePath "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -Credential $cred -ArgumentList $args -WorkingDirectory "C:\Windows\System32\WindowsPowerShell\v1.0\"
- Alexander Riedel
- Posts: 8488
- Last visit: Tue Apr 16, 2024 8:42 am
- Been upvoted: 37 times
Re: Powershell command not work when compiled
From your description you are launching the executable from a user folder (like 'My Documents') and the elevate to admin. That will make the user folder invalid.
Start-process the tries to use the current folder as current directory but has no rights to access it.
In general you should never place any applications that use elevation or another user during its process into a user specific folder, as files and folders
Start-process the tries to use the current folder as current directory but has no rights to access it.
In general you should never place any applications that use elevation or another user during its process into a user specific folder, as files and folders
Alexander Riedel
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.
-
- Posts: 20
- Last visit: Thu Mar 09, 2023 4:36 am
- Has voted: 1 time
Re: Powershell command not work when compiled
Yes ! I dont know the trick before.
Thanks for your time helping me
Thanks for your time helping me