header image

Archive for July, 2013

AD Management MEAP

Posted by: | July 15, 2013 | No Comment |

A new MEAP was released last week for AD Management in a Month of Lunches.  Chapters 1-15 are now available http://www.manning.com/siddaway3/

under: Active Directory, Books, PowerShell original, Windows Server 2012

PowerShell is more or less case insensitive so the operation in my previous post $_.Substring(3,1) -ne "T" will trigger on “T” or “t” If you only want the uppercase version to fail then you can use the case sensitive version of –ne  which is –cne. This changes the script to: function ptest { [CmdletBinding()] param( […]

under: PowerShell Basics

Validating parameters

Posted by: | July 8, 2013 | No Comment |

PowerShell provides a number of ways of validating the values input to the parameters in your scripts. One such way is Validate script. I came across an interesting question where the inquirer wanted to test an input parameter and throw an error if the 4th character was a “T” One solution is: function ptest { […]

under: PowerShell Basics, PowerShell V3

Measure-Object

Posted by: | July 7, 2013 | No Comment |

One cmdlet that I don’t think gets used enough is Measure-Object. This enables you to find the minimum, maximum, sum and average of a set of numbers coming down the pipeline PS> 1..12 | Measure-Object -Sum -Maximum -Minimum -Average Count    : 12 Average  : 6.5 Sum      : 78 Maximum  : 12 Minimum  : 1 Property […]

under: PowerShell Basics

Following on from the last post this is how you can delete a file. Use the same file structure as previously This time you need to use the CIM_DataFile class. It’s one of the few classes I’ve found that doesn’t have a Win32_ equivalent. The class has a Delete method.  Assuming you know the full […]

under: File System, PowerShell and WMI, PowerShell V3

I recently saw a question about deleting folders with WMI. Let’s create a file structure we’re happy to delete New-Item -Path c:\ -Name Expendable -ItemType Directory New-Item -Path c:\Expendable -Name Target1  -ItemType Directory New-Item -Path c:\Expendable -Name Target2  -ItemType Directory Get-Process | Out-File -FilePath c:\Expendable\Target1\proc.txt Get-Service | Out-File -FilePath c:\Expendable\Target2\serv.txt   A look through the […]

under: File System, PowerShell and WMI, PowerShell V3

Excel–named range

Posted by: | July 5, 2013 | No Comment |

To create a named range in an Excel spreadsheet $xl = New-Object -ComObject ‘Excel.Application’ $wkbk = $xl.Workbooks.Add() $sheet = $wkbk.WorkSheets.Item(1) $range = $xl.Range("A1", "D4") $range.Name = "Test" Just to show how to work with named ranges $range2 = $xl.Range("Test") $range2.Borders.Color=0 $range2.Borders.ColorIndex=26 $range2.Borders.Weight=2 $xl.visible = $true

under: Office 2013, PowerShell V3

The updatable help in PowerShell 3.0 caused a lot of confusion when that version first shipped. The help files have been updated periodically since 3.o shipped but its always been difficult finding out when they’ve been updated. That’s changed There is now an RSS feed that provides information on updates to the help files. Written […]

under: PowerShell V3, PowerShell v4

Just been puzzling out why I haven’t been getting any RSS feeds for a few days.  Looks like when I hooked up my Office365 account to Outlook it took out all the RSS feeds.  Fun time to come putting them back

under: Office 2013

Office365 ate me RSS feeds

Posted by: | July 3, 2013 | No Comment |

Just been puzzling out why I haven’t been getting any RSS feeds for a few days.  Looks like when I hooked up my Office365 account to Outlook it took out all the RSS feeds.  Fun time to come putting them … Continue reading →

under: Office 2013

« Newer Posts - Older Posts »

Categories