Richard's profileRichard Siddaway's BlogPhotosBlogLists Tools Help

Blog


    March 06

    PSDrive

    I started thing about the troubleshooting packs we were looking at in the last post.  They are good but getting to them is a bit too hard.  We can short cut some of it by creating a PowerShell drive.  One of the great things about PowerShell is the provider system that exposes different data stores as if they were the file system – well this works for the file system as well.

    Import the module as before

    Import-Module troubleshootingpack

    We don’t need a path because it is in the modules folder of the PowerShell install directory so it is automatically found.

    Next thing we do is create a drive

    New-PSDrive -Name tspack -PSProvider FileSystem -Root "C:\Windows\diagnostics\system" -Description "Maps to the troubleshooting packs"

    Now when we look at the drives

    PS> Get-PSDrive

    Name       Provider      Root
    ----       --------      ----
    Alias      Alias
    C          FileSystem    C:\
    cert       Certificate   \
    D          FileSystem    D:\
    E          FileSystem    E:\
    Env        Environment
    Function   Function
    HKCU       Registry      HKEY_CURRENT_USER
    HKLM       Registry      HKEY_LOCAL_MACHINE
    tspack     FileSystem    C:\Windows\diagnostics\system
    Variable   Variable
    WSMan      WSMan

    Notice our new drive.

    We can now access the troubleshooting system like this

    PS> ls tspack:

        Directory: C:\Windows\diagnostics\system

    Mode                LastWriteTime     Length Name
    ----                -------------     ------ ----
    d----        13/12/2008     15:33            AERO
    d----        13/12/2008     15:33            Audio
    d----        13/12/2008     15:33            Device
    d----        13/12/2008     15:33            DeviceCenter
    d----        13/12/2008     15:33            HomeGroup
    d----        13/12/2008     15:33            IEBrowseWeb

    Yes Virginia I did use an alias.  Its only in scripts or published stuff that  I don’t like them.

    And we can use the packs

    Get-TroubleshootingPack -Path tspack:\networking

    If you are going to be using these things a lot then the two lines

    Import-Module troubleshootingpack

    New-PSDrive -Name tspack -PSProvider FileSystem -Root "C:\Windows\diagnostics\system" -Description "Maps to the troubleshooting packs"

    should be added to your profile or loaded as a function for immediate use.

    The psdrive functionality can be used to create a lot of shortcuts like this.

     

    Comments

    Please wait...
    Sorry, the comment you entered is too long. Please shorten it.
    You didn't enter anything. Please try again.
    Sorry, we can't add your comment right now. Please try again later.
    To add a comment, you need permission from your parent. Ask for permission
    Your parent has turned off comments.
    Sorry, we can't delete your comment right now. Please try again later.
    You've exceeded the maximum number of comments that can be left in one day. Please try again in 24 hours.
    Your account has had the ability to leave comments disabled because our systems indicate that you may be spamming other users. If you believe that your account has been disabled in error please contact Windows Live support.
    Complete the security check below to finish leaving your comment.
    The characters you type in the security check must match the characters in the picture or audio.

    To add a comment, sign in with your Windows Live ID (if you use Hotmail, Messenger, or Xbox LIVE, you have a Windows Live ID). Sign in


    Don't have a Windows Live ID? Sign up

    Trackbacks

    The trackback URL for this entry is:
    http://richardsiddaway.spaces.live.com/blog/cns!43CFA46A74CF3E96!2126.trak
    Weblogs that reference this entry
    • None