Internship assignment. Script that checks all systems in a domain and their uptime.


just warning before hand. have 0 knowledge in powershell. know little how edit existing scripts though.

the title self explanatory. i'm building script searches systems in domain. needs record findings in excel.

right have this:

function get-systems {
param ( 
[parameter(mandatory=$true)] [string] $domain )

get-adcomputer -filter {name -like $domain} -properties lastlogontimestamp | select name, @{n='lastlogontimestamp'; e={[datetime]::fromfiletime($_.lastlogontimestamp)}} | out-excel

}

i know, there's lot wrong here. anyway, still need figure out way filter on domain parameter(what i've got doesn't work). , last, need find way uptime of systems. i've used lastlogontimestamp , hoped figure out there, without success.

i'm stuck. have no clue go next.
appreciated.

thank you.


this why intern.  need take time learn windows, ad , powershell.  start getting books on these technologies cannot guess way through this.

the last logon date not give want can as 14 days old.

you need start time using wmi.

get-wmiobject win32_operatingsystem -computer $computer  | select pscomputername, lastbootuptime


\_(ツ)_/



Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

Azure MFA with Azure AD and RDS

Failed to setup initiator portal. Error status is given in the dump data.

Invalid pointer on gpresult /h gpreport.html