Hello everybody!
I’m new to PowerShell, so I’m asking for help with customizing the script.
I got a list of computers in the domain besides the domain itself and saved it to csv while trying to add the “checked” flag
and then browse the file looking for “not installed” + “available”
install there.
How to implement it?
Start-Transcript;
$list = Get-ADComputer -Filter * -Property * | Select-Object Name | Export-CSV -path ‘C:\ADcomputerslist.csv’
$all=Import-csv -path ‘C:\ADcomputerslist.csv’
$computer = (Get-ADComputer -LDAPFilter “(&(objectCategory=computer)(!userAccountControl:1.2.840.113556.1.4.803:=8192))” -Properties name | Sort).name;
$testpath = “\$computer\c$\fusion”
foreach ($comp in $all) {
if (-not $comp.installed -and
(test-connection $comp.name) -and
(-not (test-path $testpath))
Invoke-Command -computername $comp.name -ScriptBlock {powershell “& ‘C:\fusion\fusion.bat’” –ThrottleLimit 120}
$comp.installed=$true
}
}
$all | Export-CSV -path ‘C:\installed.csv’
and two part of script
$sourcefile = “\WIN-OPCVL1KQ9EF\c$\fusion*”
foreach ($computer in $computername)
{
$destinationFolder = “\$computer\c$\fusion”
if (!(Test-Path -path $destinationFolder))
{
New-Item $destinationFolder -Type Directory
}
Copy-Item -Path $sourcefile -Destination $destinationFolder;
Invoke-Command -ComputerName $computer -ScriptBlock {powershell -Command Add-MpPreference -ExclusionPath "C:\fusion";powershell "& 'C:\fusion\fusion.bat'"} –ThrottleLimit 120
}