header image

Archive for January, 2011

I haven’t finished with the WScript.Shell object and we will return to it.  This time I want to look at the FileSystem object. If you have worked with VBScript and files you will be familiar with this object.  While we have techniques in PowerShell to perform many of the same tasks there are still a […]

under: COM, PowerShellV2

COM pt 4

Posted by: | January 30, 2011 | 1 Comment |

If you have been following along so far you may be thinking that you can use ls env: to view the environmental variables. True. But if you compare the output of part 3, the PowerShell enc: drive and getting the environmental variables via WMI you will find that they aren’t identical. The point of this […]

under: COM, PowerShellV2

COM pt 3–More shell

Posted by: | January 29, 2011 | 1 Comment |

Last time we looked at the Environment parameterized property If you ran the script in part two the output would have contained things like windir=%SystemRoot% We need to be able to resolve the variable %SystemRoot% part to the full path 001 002 003 004 005 006 007 008 009 010 011 012 013 014 $wshell = New-Object -ComObject "WScript.Shell" […]

under: COM, PowerShellV2

Reminder 1

Posted by: | January 29, 2011 | No Comment |

Quick reminder that the UK PowerShell UG meeting for February is coming up soon. Details from here http://msmvps.com/blogs/richardsiddaway/archive/2011/01/18/uk-user-group-february-live-meeting.aspx   That reminds me – I’d better write the presentation 

under: PowerShell User Group, PowerShellV2

Science or Art

Posted by: | January 28, 2011 | No Comment |

Infrastructure Architecture = Science or Art. Discuss. We claim the titles of architect and/or engineer but is what we do as infrastructure architects really based on solid scientific/engineering principles. I would claim not. Much of what we do is recycling the designs of the past – possibly adapting them as new versions of particular technologies […]

under: Architecture

COM pt3–WScript.Shell

Posted by: | January 26, 2011 | No Comment |

One thing that we seem to forget when we use PowerShell is the functionality that was available to us in VBScript through the Windows Scripting Host (WSH) objects. Much of this functionality has been duplicated in PowerShell cmdlets or through .NET classes but there is still a good pile of stuff we can use.  I […]

under: COM, PowerShellV2

Watching the file arrival

Posted by: | January 25, 2011 | No Comment |

I picked up a question in the ITKE forums about a script to watch the file system   001 002 003 004 005 006 007 008 009 010 011 012 013 014 015 016 function eventhandler { param ($e)  Write-Host "File: $($e.SourceEventArgs.FullPath) has arrived" } $folder = "C:\test" $filter = "*" $fsw = New-Object -TypeName System.IO.FileSystemWatcher ` -ArgumentList $folder, $filter $fsw.IncludeSubDirectories = $true $action = {eventhandler $($event)} Register-ObjectEvent -InputObject $fsw -EventName "Created" `  -SourceIdentifier "File System Creation" -Action $action   The event handler […]

under: Events, File System, PowerShellV2

COM pt 2–More Shell

Posted by: | January 24, 2011 | No Comment |

$shell = New-Object -ComObject "Shell.Application" gets us a shell object.  We can then see the methods available to us   PS> $shell | gm -MemberType method | Format-Wide -Column 2 AddToRecent           BrowseForFolder CanStartStopService   CascadeWindows ControlPanelItem      EjectPC Explore               ExplorerPolicy FileRun               FindComputer FindFiles             FindPrinter GetSetting            GetSystemInformation Help                  IsRestricted IsServiceRunning      MinimizeAll NameSpace             Open RefreshMenu           ServiceStart ServiceStop           SetTime ShellExecute          […]

under: COM, PowerShellV2

COM pt 1

Posted by: | January 23, 2011 | No Comment |

In April I will be doing a User Group Live Meeting on using COM with PowerShell.  It is such a wide topic I thought I’d start a few posts to set some background – it also helps my reasearch COM is the way applications were built for the Windows platform before .NET appeared.  Ugh pre-historic […]

under: COM, PowerShellV2

System Restore Points

Posted by: | January 23, 2011 | No Comment |

I’ve just started a series on using the WMI system restore classes to work with remote machines at http://itknowledgeexchange.techtarget.com/powershell/ The functions developed in this series will become the next PSAM module

under: PowerShell and WMI, PowerShellV2

Older Posts »

Categories