o0Julia0o
Commander
- Registriert
- Dez. 2012
- Beiträge
- 2.796
ich probiere es so:
If (-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator"))
{
$arguments = "& '" + $myinvocation.mycommand.definition + "'"
Start-Process powershell -Verb runAs -ArgumentList $arguments
Break
}
net start FDResPub
Klappt aber nich. Ich erhalte:
Die Datei "E:\Temp\Dienst.ps1" kann nicht geladen werden, da die Ausführung von Skripts auf diesem System deaktiviert ist. Weitere Informationen finden Sie unter "about_Execution_Policies"
(https://go.microsoft.com/fwlink/?LinkID=135170).
+ CategoryInfo : Sicherheitsfehler: (
[], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : UnauthorizedAccess
Wie kann ich eine Powershell-Datei als Administrator ausführen automatisch?
If (-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator"))
{
$arguments = "& '" + $myinvocation.mycommand.definition + "'"
Start-Process powershell -Verb runAs -ArgumentList $arguments
Break
}
net start FDResPub
Klappt aber nich. Ich erhalte:
Die Datei "E:\Temp\Dienst.ps1" kann nicht geladen werden, da die Ausführung von Skripts auf diesem System deaktiviert ist. Weitere Informationen finden Sie unter "about_Execution_Policies"
(https://go.microsoft.com/fwlink/?LinkID=135170).
+ CategoryInfo : Sicherheitsfehler: (
+ FullyQualifiedErrorId : UnauthorizedAccess
Wie kann ich eine Powershell-Datei als Administrator ausführen automatisch?