From: Hey, Scripting Guy! How Can I Use Windows PowerShell to Delete All the Files in a Folder Older Than 90 Days? – Hey, Scripting Guy! Blog – Site Home – TechNet Blogs.

 

Hey, Scripting Guy! How Can I Use WindowsPowerShelltoDeleteAll the Files in a Folder Older Than 90 Days?

Hey, Scripting Guy! Question

Hey, Scripting Guy! In WindowsPowerShell, how can I determine the number of days difference between two dates? I want to be able todeleteall the files in a folder that are more than 90 days old.

— JN

SpacerHey, Scripting Guy! AnswerScript Center

Hey, JN. You know, today is October 31stand, in the US at least, it’s the day when the dark underworld takes over: witches parade through the streets, cackling and laughing; ghosts and goblins cavort on the front lawn; devils and demons come up and ring your doorbell; it’s the one day out of the year when evil truly reigns supreme. In other words, it’s – no, it’s not the Scripting Editor’s birthday (although thatwouldexplain a lot, wouldn’t it?). Instead, it’s Halloween.

Continue reading

 1,086 total views

From: Forgotten Command: systeminfo | Techish.net.

Time after time, I am asked something about a computer –  How much memory does it have?  What Windows updates are installed?  What type of network connectivity does it have…  And time after time, I send a response telling whoever is asking me to use a simple (but widely forgotten) command:

systeminfo

What does systeminfo command give you?

Description:
This tool displays operating system configuration information for
a local or remote machine, including service pack levels.

It’s a very handy tool for some quick information on a computer!

COMMAND Prompt:> systeminfo /?
SYSTEMINFO [/S system [/U username [/P [password]]]] [/FO format] [/NH]

Description:
 This tool displays operating system configuration information for
 a local or remote machine, including service pack levels.

Parameter List:
 /S      system           Specifies the remote system to connect to.

 /U      [domain\]user    Specifies the user context under which
 the command should execute.

 /P      [password]       Specifies the password for the given
 user context. Prompts for input if omitted.

 /FO     format           Specifies the format in which the output
 is to be displayed.
 Valid values: "TABLE", "LIST", "CSV".

 /NH                      Specifies that the "Column Header" should
 not be displayed in the output.
 Valid only for "TABLE" and "CSV" formats.

 /?                       Displays this help message.

Examples:
 SYSTEMINFO
 SYSTEMINFO /?
 SYSTEMINFO /S system
 SYSTEMINFO /S system /U user
 SYSTEMINFO /S system /U domain\user /P password /FO TABLE
 SYSTEMINFO /S system /FO LIST
 SYSTEMINFO /S system /FO CSV /NH

 1,451 total views

From: PowerShell script to change administrator password on a list of machines – Ying LiMVP at myITforum.com.

PowerShell script to change administrator password on a list of machines

Here is a PowerShell script to change local administrator (or any account interested) password on a list of remote machines. I am using my friend Don Hite’s VB Script as a starting point. So as always my hat off to Don!

$erroractionpreference = “SilentlyContinue”

$a = New-Object -comobject Excel.Application
$a.visible = $True

$b = $a.Workbooks.Add()
$c = $b.Worksheets.Item(1)

$c.Cells.Item(1,1) = “Machine Name”
$c.Cells.Item(1,2) = “Password Changed”
$c.Cells.Item(1,3) = “Report Time Stamp”

$d = $c.UsedRange
$d.Interior.ColorIndex = 19
$d.Font.ColorIndex = 11
$d.Font.Bold = $True

$intRow = 2

foreach ($strComputer in get-content C:\MachineList.Txt)
{
$c.Cells.Item($intRow,1)  = $strComputer.ToUpper()

# Using .NET method to ping test the servers – This is very cool!
$ping = new-object System.Net.NetworkInformation.Ping

$Reply = $ping.send($strComputer)
if($Reply.status -eq “success”)
{
# This is the Key Part
$admin=[adsi](“WinNT://” + $strComputer + “/administrator, user”)

$admin.psbase.invoke(“SetPassword”, “Whatever1”)

#$admin.psbase.CommitChanges() – I am surprised that I don’t have to do this!

# If this is for AD account, we could use PasswordLastchanged attribute. But WinNT provider does not #support the PasswordLastChanged attribute!

# I was trying to use passwordage attribute value but somehow I found it give you the value for last time, #may be because there is a delay for this attribute to propagate. So I made an “executive” decision to test #if passwordage is $null – so this may not be 100% accurate.

$pwage = $admin.passwordage

If($pwage -ne “0”)
{
$c.Cells.Item($intRow,2).Interior.ColorIndex = 4
$c.Cells.Item($intRow,2) = “Yes”
}
Else
{
$c.Cells.Item($intRow,2).Interior.ColorIndex = 3
$c.Cells.Item($intRow,2) = “No”
}
}
Else
{
$c.Cells.Item($intRow,2).Interior.ColorIndex = 3
$c.Cells.Item($intRow,2) = “Not Pingable”
}

$c.Cells.Item($intRow,3) = Get-Date

$Reply = “”
$pwage = “”
$intRow = $intRow + 1
}
$d.EntireColumn.AutoFit()

cls

Posted: Aug 23 2007, 11:23 AM by yli628 | with 3 comment(s)

Filed under: 

 1,309 total views

WordPress Appliance - Powered by TurnKey Linux