Saturday, January 31, 2009
Sunday, January 25, 2009
rename computer
$ComputerInfo = Get-WmiObject -Class Win32_ComputerSystem
$ComputerInfo.rename($NewComputerName)
}
This script shows you how to rename computer by using WMI
How to use it :
& .\rename-computerName.ps1
rename-computername "MyNewComputerNAME"
And to reboot you can use WMI class Win32_OperatingSystem and its method reboot():
$OS = Get-WmiObject -Class Win32_OperatingSystem
$OS.reboot()
OR
shutdown -r -t 10 -f -c "Restart OS"
Users of PowerShell V2 (currently CTP3) can use the Restart-Computer cmdlet too. :)
DETAILED DESCRIPTION
The Restart-Computer cmdlet restarts the operating system on the local and remote computers.
You can use the parameters of Restart-Computer to run the restart operations as a background job, to specify the authentication levels and alternate credentials, to limit the operations that run concurrently, and to force an immediate restart.
This cmdlet does not require Windows PowerShell remoting unless you use the AsJob parameter.
Friday, January 23, 2009
Get-QADComputer Lastlogintime
also switched lastLogonTimeStamp with pwdLastSet
Re: Get-QADComputer Lastlogintime
Posted: Dec 16, 2008 7:29 AM in response to: alex.stefishen@...
Answered
Reply
Sure. :-)
$limit = (get-date).AddDays(-30).ToFileTime()
$filter = "(&(objectcategory=computer)(|(lastLogonTimestamp<=$limit)(!(lastLogonTimestamp=*))))" $inactivecomputers = Get-QADComputer -ldapFilter $filter -ip lastlogontimestamp -SizeLimit 0 $inactivecomputers | ft name,@{l="LastLogonTimeStamp";e={if($_.lastLogonTimestamp -ne $null){[DateTime]::FromFileTime([Int64]::Parse($_.lastLogonTimestamp))}} } -autosize
Tuesday, January 13, 2009
regular expressions
Windows PowerShell: Writing Regular Expressions
More Powershell RegEx fun (playing with ‘route Print’)
Regular expressions in PowerShell and Perl
Windows PowerShell in Action: Working With Text and Files in ...
Regular Expressions with Windows PowerShell
The PowerShell Guy : Regular Expressions and PowerShell Part 1
The PowerShell Guy : Regular Expressions and PowerShell Part 2
Effective PowerShell Item 9: Regular Expressions - One of the ...
Regular Expression HOWTO
Learning to Use Regular Expressions
Regular Expressions - a Simple User Guide
What the Heck is a Regular Expression Anyway?
Regular Expression Library
How To: Use Regular Expressions to Constrain Input in ASP.NET
Regex tutorial by Gerd Ewald
Tuesday, January 6, 2009
Saturday, January 3, 2009
Get-QADComputer Lastlogintime
$limit = (get-date).AddDays(-30).ToFileTime()
$filter = "(&(objectcategory=computer)(|(lastLogonTimestamp<=$limit)(!(lastLogonTimestamp=*))))" $inactivecomputers = Get-QADComputer -ldapFilter $filter -SizeLimit 0
It's faster than piping to where-object.
$limit = (get-date).AddDays(-30).ToFileTime()
$filter = "(&(objectcategory=computer)(|(lastLogonTimestamp<=$limit)(!(lastLogonTimestamp=*))))"
$inactivecomputers = Get-QADComputer -ldapFilter $filter -ip lastlogontimestamp -SizeLimit 0
$inactivecomputers | ft name,@{l="LastLogonTimeStamp";e={if($_.lastLogonTimestamp -ne $null){[DateTime]::FromFileTime([Int64]::Parse($_.lastLogonTimestamp))}} } -autosize
-aleksandar
http://powershellers.blogspot.com