Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Create a list of active workstations and shutdown those workstations with option for the users to delay/terminate the shutdown

$
0
0

Hi,
I am new to this forum and inexperienced.  I have been assigned the task of shutting down all workstation at 8PM every day.  I have found a script (all credits) to fetch for active machine from AD and generate a list of OFF / ON workstation.  Using this list, how can I shutdown all workstation that are active so that if a users is working, he can terminate/delay the shutdown process.  I also require a 10 minute timer for the user to respond.  If no response in 10 Min, the workstation can go for shutdown.
Below is the script I am using to discover the workstations.
Appreciate any assistance and thanks in advance.

Clear-Host
Import-Module ActiveDirectory
($comp=Get-ADComputer -SEARCHBASE "DC=ps,DC=local" -Filter 'operatingsystem -notlike "*server*" -and enabled -eq "true"').Name | %{
If (Test-Connection -ComputerName $_ -Count 1 -ErrorAction SilentlyContinue)

{
      Test-Connection -ComputerName $_ -Count 1 `
    | Select @{n=’Date/Time’;e={Get-Date}},Address,IPV4Address,
    @{Name = 'Status';Expression = {'Online'}}
   
    }
Else{$_ | Select @{n=’Date/Time’;e={Get-Date}},@{Name = 'Address';Expression = {$_}},
@{Name = 'IPV4Address';Expression = {'NoAddress'}},
@{Name = 'Status';Expression = {'Offline'}}
}} | sort-object status -Descending|export-csv D:\workstation-$((Get-Date).ToString('dd-MM-yyyy')).csv -NoTypeInformation


Viewing all articles
Browse latest Browse all 15028

Latest Images

Trending Articles



Latest Images