-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRemoteinstalling_pwsh.ps1
51 lines (42 loc) · 1.29 KB
/
Remoteinstalling_pwsh.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
param([String]$acctkey,
[String]$orgkey
)
$acctkey="_ACCOUNT_KEY_"
$orgKey ="_ORGANISATION_KEY_"
$Debugprintenabled=0
$servers= Get-Content" "
$source=" "
$dest=" "
$testPath=" "
if(![String]::IsNullOrEmpty($acctkey)&![String]::IsNullOrEmpty($orgkey))
{
$OrganisationKey=$orgKey
$Accountkey=$acctkey
foreach($server in $servers)
{
if(test-Connection -Cn $computer -quiet)
{
Copy-item $source -Destination \\$computer\$dest -Recurse -Force
if(TestPath -Path $testPath)
{
Invoke-Command -ComputerName $server -ScriptBlock{powershell.exe c:\install\hascats.exe /sALl / msi /norestart ALLUSERS=1 EULA_ACCEPT=yes} }
Write-Host -ForegroundColor Green "Installation Successful on $server"
}
}else{
Write-Host -ForegroundColor Red "$Server is not online ,Installation failed"
}
}
}
function Get-TimeStamp{
return"[{0:MM/dd/yy} {0:HH:mm:ss}]" -f (Get-Date)
}
function main(){
#make sure the account key
Debug-Print("Checking for Account Key")
if ($AccountKey -eq "__ACCOUNT_KEY__") {
Write-Warning "$(Get-TimeStamp) AccountKey not set, exiting script!"
exit 1
} elseif ($AccountKey.length -ne 32) {
Write-Warning "$(Get-TimeStamp) Invalid AccountKey specified, exiting script!"
exit 1
}