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

WIMMount (HSM) causing cluster storage to go redirected (2012r2 DC)

Failed to delete the test record dcdiag-test-record in zone test.com

Azure MFA with Azure AD and RDS