-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathInstalacjaAplikacjiISS.ps1
66 lines (51 loc) · 2.29 KB
/
InstalacjaAplikacjiISS.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
###########################################################
function Get-Connection
{
[CmdletBinding()]
param (
[Parameter(HelpMessage = "Packet name to install application")]
[Alias("Computers")]
[string]$packetName
)
$path=(Get-Location).Path
$issFilepath=(Get-ChildItem -Path $path).Name
$computerNames=Get-Content -Path $(Join-Path -Path $path -ChildPath "stacje.txt")
$output=[PSCustomObject]@{}
$computerNames | ForEach-Object {
$output | Add-Member -MemberType "NoteProperty" -Name $($_) -Value $($_)
$connection=(Test-Path "\\$($_)\C$")
if ($connection)
{
$output | Add-Member -MemberType "NoteProperty" -Name $($_) -Value $connection
$tempInstallationPath="\\$($_)\instalacje\$packetName"
if (-not(Test-Path -Path $tempInstallationPath))
{
New-Item -Path $tempInstallationPath -ItemType Directory
}
$installPacketPath=Join-Path -Path $path -ChildPath $packetName
Copy-Item -Path $installPacketPath -Destination $tempInstallationPath -Recurse
$pstoolsPath = "\\$($_)\C$\Windows\System32"
if (-not (Test-Path -Path $pstoolsPath))
{
Copy-Item -Path "$path\pstools\PsExec.exe" -Destination $pstoolsPath
}
pstools\psexec -accepteula -nobanner \\$($_) "$tempInstallationPath\setup.exe" -s -f1"$issFilePath\setup.iss"
Remove-Item -Path $tempInstallationPath -Recurse
$applicationName=$packetName.Split("_")[0]
if(Test-Path -Path "\\$($_)\C$\$applicationName\$applicationName.exe" -PathType leaf)
{
$output | Add-Member -MemberType "NoteProperty" -Name Version -Value (((Get-ChildItem -Path "\\$($_)\C`$\$applicationName\$applicationName.exe").VersionInfo).ProductVersion)
}
else
{
$output | Add-Member -MemberType "NoteProperty" -Name Version -Value "ERROR"
}
}
else
{
$output | Add-Member -MemberType "NoteProperty" -Name $($_) -Value "Not Available"
$output | Add-Member -MemberType "NoteProperty" -Name Version -Value "Not Connected"
}
}
$output
}