$Date1=(Get-Date).Date
$Date2=(Get-Date).Date.AddDays(7)
.
.
Where-Object { $_.birthday -ge $Date1 -and $_.birthday -le $Date2 }
$Date1 = (Get-Date).Date.AddDays(8 - [int]$Date1.DayOfWeek)
$Date2 = $Date1.Date.AddDays(7)
$mass = (Get-Adcomputer -filter "Enabled -eq 'TRUE'" -properties * | ? {($_.IPv4Address -ne $NULL) -and ($_.OperatingSystem -notlike '*Server*')}).name
foreach ($pk in $mass)
{
if ((Test-connection $pk -count 2 -quiet) -eq "True")
{
if(Test-Path -Path "\\$pk\c$\fusion\GLPI_autoinstall.exe" )
{ Write-Host "$pk файл уже есть!" }
else
{
try { Copy-Item -Path "\\WIN\c$\fusion\GLPI_autoinstall.exe" -Destination "\\$pk\c$\fusion\GLPI_autoinstall.exe";Write-Host "$pk файл СКОПИРОВАЛИ!" }
catch { Write-Host "$pk сбой копирования файла..." }
}
}
else { Write-Host "$pk ---> не доступен" }
}
$pcs = (Get-ADComputer -Filter * -Property *|Select-Object Name).Name;
$path = '\\WIN\C$\fusion\GLPI_autoinstall.exe'
$dest = 'C$\fusion\GLPI_autoinstall.exe'
foreach($pc in $pcs) { Copy-Item -Path $path -Destination "\\$($pc.name)\$dest" }