1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| $Username = "administrateur"
$Key = [byte]35,31,32,45,55,11,09,08,11,34,67,99,12,20,09,98
$Password = "76492d1116743f0423413b16050a5345MgB8AEEAUQBaAFIATAA4AHcAKwArAHgASwByADcAcQBiAHcAawBOADgAYwBLAFEAPQA9AHwANQBmADkANwBiADUAMwBmAGIAYwA0AGIAZAA2AGQAOAA0AGYANQAxADgANwBiAGMAYwAzADIAZgA2AGYAMwAzAGYANQBkADEAYQBiADAAMgBkAGEAMQA0ADIAMwAzADIAMgA0ADUAZgA4ADAAYgBlADgANABlADUAYQA5ADcAOAA=" | ConvertTo-SecureString -Key $Key
if (-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator"))
{
$Credential = New-Object System.Management.Automation.PSCredential($UserName, $Password)
Start-Process powershell.exe -Credential $Credential -NoNewWindow -ArgumentList "Start-Process powershell.exe -Verb runAs -ArgumentList '-File', $PSCommandPath"
break
}
# La deuxième partie ici
Stop-Service "OCS inventory service"
Copy-Item -Path \\192.168.16.25\Public\ocsinventory.ini -Destination "C:\ProgramData\OCS Inventory NG\Agent\" -Force
Start-Service "OCS inventory service" |
Partager