Trap [Exception] { “In PowerShell” }
http://huddledmasses.org/trap-exception-in-powershell/
Read MoreLog on to the HP iLo using SSH and execute the following commands (in BOLD)…
</>hpiLO-> cd /map1
status=0
status_tag=COMMAND COMPLETED</map1>hpiLO-> reset
status=0
status_tag=COMMAND COMPLETED
Resetting iLO.CLI session stopped
Your SSH session will be terminated and should be able to connect via the web interface.
Read MoreHere are the steps that i followed to create a bootable USB drive. Also if you have a USB drive that has U3 installed on it you may want to uninstall it prior to continuing. Here are the instructions on how to uninstall U3 http://www.u3.com/uninstall
Format the Flash Drive
Run CMD.EXE and type the following. Note: This set of commands assumes that the USB flash drive is addressed as ”disk 1″. you should double check that by doing a list of the disks (type “list disk”) before cleaning it.
Copy the Contents of the DVD to the USB Drive
Simply issue the following command to start copying all the content from the Windows 7 DVD to your newly formatted high speed flash drive.
And that’s it. Boot up the machine, have it boot off the USB drive, and watch how fast the installation completes.
Read Morehere is a script to rename the local administrator password using powershell… it renames the administrator account to the “!computerName”…
Remember to run powershell as administrator.
$Bang = “!”
$NewComputerName = gc env:computername
$NewAdminAccount = $Bang+$NewComputerName $admin = [ADSI]“WinNT://./Administrator,user” $admin.psbase.Rename(“$NewAdminAccount”)
A way to test to see if the server is pingable
PS > # Using .NET method to ping test the servers
PS > $ping = new-object System.Net.NetworkInformation.Ping
PS > $ping.send($strComputer)
Status : Success
Address : 192.168.1.1
RoundtripTime : 0
Options : System.Net.NetworkInformation.PingOptions
Buffer : {97, 98, 99, 100…}
# Using .NET method to ping test the servers
$ping = new-object System.Net.NetworkInformation.Ping
$Reply = $ping.send($strComputer)
if($Reply.status -eq “success”)
{
#Do something here …
}
Here are a few fuctions on how to create, update and extract a zip file within powershell.
1. Create a New Zip
function New-Zip{
param([string]$zipfilename)
set-content $zipfilename (“PK” + [char]5 + [char]6 + (“$([char]0)” * 18))
(dir $zipfilename).IsReadOnly = $false}
usage: new-zip c:demomyzip.zip
2. Add files to a zip via a pipeline
function Add-Zip
{param([string]$zipfilename)
if(-not (test-path($zipfilename))){
set-content $zipfilename (“PK” + [char]5 + [char]6 + (“$([char]0)” * 18))
(dir $zipfilename).IsReadOnly = $false}
$shellApplication = new-object -com shell.application
$zipPackage = $shellApplication.NameSpace($zipfilename)
foreach($file in $input)
{
$zipPackage.CopyHere($file.FullName)
Start-sleep -milliseconds 500
}}
usage: dir c:zipFiles*.* -Recurse | add-Zip c:zipFile.zip
3. List the files in a zip
function Get-Zip
{
param([string]$zipfilename)
if(test-path($zipfilename)){
$shellApplication = new-object -com shell.application
$zipPackage = $shellApplication.NameSpace($zipfilename)
$zipPackage.Items() | Select Path}
}
usage: Get-Zip c:zipFile.zip
4. Extract the files form the zip
function Extract-Zip
{
param([string]$zipfilename, [string] $destination)
if(test-path($zipfilename)){
$shellApplication = new-object -com shell.application
$zipPackage = $shellApplication.NameSpace($zipfilename)
$destinationFolder = $shellApplication.NameSpace($destination)
$destinationFolder.CopyHere($zipPackage.Items())}
}
usage: extract-zip c:zipFile.zip c:destination
Read MoreA good source of information.
http://www.computerperformance.co.uk/powershell/powershell_variables.htm
Read More