-
-
Save Wolvverine/f1049df31e4ef2176edb204480b62f3c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
.SYNOPSIS | |
Script install FusionInventoryAgent | |
.DESCRIPTION | |
Script install FusionInventoryAgent | |
.EXAMPLE | |
PS C:\> <example usage> | |
Explanation of what the example does | |
.INPUTS | |
Inputs (if any) | |
.OUTPUTS | |
Output (if any) | |
.NOTES | |
Wojtek | 08/2018 | |
#> | |
[cmdletbinding()] | |
param ( | |
) | |
begin { | |
$FusionFilePath = "<sciezka do exe>" | |
$TestComputerList = Get-ADComputer -SearchBase 'OU=domena,OU=domena,DC=domena,DC=domena' -Filter * | Select-Object -ExpandProperty Name | |
} | |
process { | |
# Test Connection to Computer | |
$FilteredComputers = @() | |
$FailToConnect = @() | |
foreach ($computer in $TestComputerList) { | |
try { | |
$ComputerTest = Test-Connection -ComputerName $computer -Count 1 -ErrorAction Stop | |
if ($ComputerTest) { | |
$FilteredComputers += $computer | |
} | |
} | |
catch { | |
$FailToConnect += $computer | |
} | |
} | |
# | |
$FailTable = @() | |
foreach ($FilteredComputer in $FilteredComputers) { | |
Write-Host "$FilteredComputer" | |
try { | |
Copy-Item -Path $FusionFilePath -Destination "\\$FilteredComputer\c$" -ErrorAction Stop | |
Start-Sleep -Seconds 1 | |
Invoke-Command -ComputerName $FilteredComputer -AsJob -ScriptBlock { | |
([WMICLASS]"\\localhost\ROOT\CIMV2:win32_process").Create("<sciezka do exe na komputerze uzytkownika> /S /acceptlicense /execmode='Service' /installtasks='Full' /installtype='from-scratch' /scan-homedirs /scan-profiles /server='<sciezka do glpi>' /runnow") | Out-Null | |
} | |
} | |
catch { | |
$FailTable += $FilteredComputer | |
} | |
} | |
} | |
end { | |
Write-Host "------------ Fail To Connect -----------------------" | |
$FailToConnect | |
Write-Host "------------ Fail To Install -----------------------" | |
$FailTable | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment