09 July 2014

Set Active Directory user property's with Powershell

Need to edit a user property here's how:


To set the Dail-in property to deny access, you look for the corresponding value, in this case:
"msNPAllowDailin" which is set to TRUE.

In Powershell you type:set-ADUser username -Replace @{msnpallowdialin=$false}

Now when you look at the same value in the attribute editor it displays FALSE.


I haven't tried it but i guess everything that has a value can be changed or edited by the same command.
If you know some others, or disagree let me know.




Get system up time script and alternative ways

Save as a ps1 script, and run.

$computer = "computername"

$lastboottime = (Get-WmiObject -Class Win32_OperatingSystem -computername $computer).LastBootUpTime

$sysuptime = (Get-Date) – [System.Management.ManagementDateTimeconverter]::ToDateTime($lastboottime) 
  
Write-Host "$computer has been up for: " $sysuptime.days "days" $sysuptime.hours "hours" $sysuptime.minutes "minutes" $sysuptime.seconds "seconds" 

Outputs like:

PS D:\_DATA\Scripts> .\Uptime.ps1
computername has been up for:  71 days 4 hours 26 minutes 50 seconds

Alternatives:

1. Go to "Start" -> "Run".

2.  Write "CMD" and press on "Enter" key.

3. Write the command systeminfo | find "up time" and press on "Enter" key.

1. Go to "Start" -> "Run".

2.  Write "CMD" and press on "Enter" key.

3.  Write the command "net statistics server" and press on "Enter" key.


4.  The line that start with "Statistics since …" provides the time that the server was up from.

  •   The command "net stats srv" can be use instead.
Uptime.exe Tool Allows You to Estimate Server Availability with Windows NT 4.0 SP4 or Higher

Source

Alternate source