Sorry for my bad English.
I wanted to ask if there is a solution for this problem.
Run powershell in administrator mode and then run a command that writes to me in a file the characteristics of the host it runs on.
By executing these commands:
Start-Process-Verb RunAs PowerShell
$ computers = Get-WmiObject-Class Win32_ComputerSystem
$ computer | out-file c: \ filename.txt
the thing works.
I tried to put these lines in a file .ps1 and run
What happens is that I open powershell, run the first line (Start-Process PowerShell-Verb RunAs), which in turn opens a new shell in administrator mode but then the execution of subsequent commands continue in the original shell (the one without administrator rights) and it generates error.
In practice, I wanted to ask if there is a way to pass the commands in the .ps1 from the shell normal in to with administrative rights.
Thank you
↧
Powershell Ruan As Administrator
↧