April 2007 - Posts
Here is an refurbished version of my previous script about getting Nic driver informations:
$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) = "Network Adapter"
$c.Cells.Item(1,3) = "Driver Provider"
$c.Cells.Item(1,4) = "Driver Date"
$c.Cells.Item(1,5) = "Driver Version"
$c.Cells.Item(1,6) = "Digital Signer"
$c.Cells.Item(1,7) = "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
$PnP = Get-WMIObject Win32_PnPSignedDriver -computer $strcomputer |where {$_.Devicename -like "HP NC*"}
Foreach ($Nic in $PnP)
{
$c.Cells.Item($intRow,2) = $Nic.Devicename
$c.Cells.Item($intRow,3) = $Nic.DriverProviderName
$strDate = $Nic.DriverDate
$z = $strDate.substring(0,8)
$dtyear = $z.substring(0,4)
$dtmonth = $z.substring(4,2)
$dtday = $z.substring(6,2)
$driverdate = "$dtmonth" + "/"+ "$dtday" + "/" + "$dtyear"
$c.Cells.Item($intRow,4) = [DateTime]$DriverDate
$c.Cells.Item($intRow,5) = $Nic.DriverVersion
$c.Cells.Item($intRow,6) = $Nic.Signer
$c.Cells.Item($intRow,7) = Get-Date
$intRow = $intRow + 1
}
}
$d.EntireColumn.AutoFit()
cls
Here is a powershell script to get Nic Driver Information for a list of machines:
Foreach ($strComputer in get-content C:\MachineList.Txt)
{
$PnP = Get-WMIObject Win32_PnPSignedDriver -computer $strcomputer |where {$_.Devicename -like "HP NC*"}
$strComputer
foreach ($Nic in $PnP)
{
"NetWork Adapter Name: $($Nic.Devicename)"
"Network Adapter Driver Version: $($Nic.DriverVersion)"
}
}
Every now and then in my work, I need to compare excel sheets, like which clients managed by SMS also managed by opsware(or not). It is really a pain to compare those excel sheets line by line or search to filter hundreds out of thousands!
I wrote the below PowerShell script to make my life (now yours also) easier.
What it does is to create two arrays out of the two target lists. And then use the PowerShell containment operators to sort out the difference and write the results to text files.
Now you can cut down otherwise hours work to minutes. (Don’t let your boss know you have this tool – you could get a couple of hours break!
)
$arrFirst = get-content First.txt
$arrSecond = get-content Second.txt
New-Item "C:\Myworkplace\ps\FirstInSecond.txt" -Type file
New-Item "C:\Myworkplace\ps\FirstNotInSecond" -Type file
Foreach ($First in $arrFirst)
{
If ($arrSecond -contains $First)
{Add-content "C:\Myworkplace\ps\FirstInsecond.txt" $First}
Else
{Add-content "C:\Myworkplace\ps\FirstNotInSecond.txt" $First}
}
Here is a little PowerShell script to find all the processes on a computer that started today.
Get-Process | Where {$_.starttime -ge [datetime]::today}
You can change to any day of interest.
Get-Process | Where {$_.starttime -eq [datetime]::4/16/2007}
If someone ever asks you,” How long is it till new year (or any day for that matter)?” Below is a little PowerShell date math routine I borrowed from Jeffrey Snover, the architect of PowerShell.
Function TillNewYear
{
$Now = [DateTime]::Now
[Datetime]([string] ($now.Year + 1) + "-01-01") - $Now
}
TillNewYear
The Glycemic index is a measure of how high your blood sugar rises after eating a fixed amount of carbohydrate. It is expressed in the form of number that gives an estimate of how quickly that food is converted to sugar in our bodies. Glucose is the most common standard at 100.
The higher the number, the more quickly that food is converted . One of the highest numbers belongs to white bread, which has a glycemic index of 70. White bread can be converted to sugar very easily and quickly. Lima beans, on the other hand, have a glycemic index of 45, lentils 40, Peanuts 20.
Below is a link to a glycemic table for reference:
Glycemic Index Table
Generally, the more slowly a carbohydrates is converted to glucose, the better is for our health.
Other characters in the mix, the fiber, the fat or the proteins that in combination will slow the absorption of sugar into the system. Those are important variables.
For instance, although a rice cake has a high glycemic index, if you spread almond butter over it, the glycemic index drops dramatically. This may seem paradoxical, but adding the nut butter adds some protein, fat, and fiber to the carbohydrate of the rice cake. The addition of protein, fat, and fiber to a food slows down how quickly the body can convert the carbohydrate to glucose.
This is another reason why it is not healthy for people on a low fat and high carbohydrate diet.