Windows Vista Forums

Pipe Yes or No to cmdlet
  1. #1


    Patrick Fitchie Guest

    Pipe Yes or No to cmdlet

    I am trying to schedule via windows scheduler the execution of the following
    script:

    -------------------Begin SCRIPT-------------------
    param ([string] $DPMServerName, [string] $LibraryName)



    if (!(Get-PSSnapin microsoft.dataprotectionmanager.powershell))
    {write-host "Adding PS Snapin for DPM..." -Fore Green
    add-PSSnapin Microsoft.DataProtectionManager.PowerShell}

    if(("-?","-help") -contains $args[0])
    {
    Write-Host "Usage: UnlockLibrary.ps1 [[-DPMServerName] <Name of the DPM
    server>] [-LibraryName] <Name of the library>"
    Write-Host "Example: UnlockLibrary.ps1 -DPMServerName
    MyDPMServer.domain.local -LibraryName "My library""
    exit 0
    }

    if (!$DPMServerName)
    {
    $DPMServerName = Read-Host "DPM server name: "
    if (!$DPMServerName)
    {
    Write-Error "Dpm server name not specified."
    exit 1
    }
    }

    if (!$LibraryName)
    {
    $LibraryName = Read-Host "Library name: "
    if (!$LibraryName)
    {
    Write-Error "Library name not specified."
    exit 1
    }
    }

    if (!(Connect-DPMServer $DPMServerName))
    {
    Write-Error "Failed to connect To DPM server $DPMServerName"
    exit 1
    }

    $library = Get-DPMLibrary $DPMServerName | where {$_.UserFriendlyName -eq
    $LibraryName}

    if (!$library)
    {
    Write-Error "Failed to find library with user friendly name $LibraryName"
    exit 1
    }

    Unlock-DPMLibraryDoor -DPMLibrary $library

    -------------------END SCRIPT-------------------

    The problem is Unlock-DPMLibraryDoor prompts for a Yes or No to continue and
    MS DPM Team has not provided a parameter to specify this. How can I
    effectively echo the response to the console like you would in a dos cmd
    (echo Y | Unlock-DPM....)

    Any help would be greatly appreaciated.

      My System SpecsSystem Spec

  2. #2


    Hal Rottenberg [MVP] Guest

    Re: Pipe Yes or No to cmdlet

    Patrick Fitchie wrote:

    > Unlock-DPMLibraryDoor -DPMLibrary $library

    > The problem is Unlock-DPMLibraryDoor prompts for a Yes or No to continue and
    > MS DPM Team has not provided a parameter to specify this.
    Patrick, try this. It may not work--but it really should if the DPM team has
    done their homework. I don't have the snapin to try it out myself.

    Unlock-DPMLibraryDoor -DPMLibrary $library -Confirm:$false

    Let us know how it goes. If this does not work, we really need to push back to
    that team so that they implement this common powershell convention.


    --
    $signature = "Hal Rottenberg, MVP - Admin Frameworks"
    $projects = @{ title = "Blog Author"; url = "http://halr9000.com" },
    @{ title = "Co-host"; url = "http://powerscripting.net" },
    @{ title = "Community Director"; url = "http://PowerShellCommunity.org" },
    @{ title = "Psi Webmaster"; url = "http://psi-im.org" }

      My System SpecsSystem Spec

  3. #3


    Patrick Fitchie Guest

    Re: Pipe Yes or No to cmdlet

    Hi Hal,

    Thanks for your response. Unfortunately the DPM team has not included the
    common convention and does not work.

    Patrick

    "Hal Rottenberg [MVP]" wrote:

    > Patrick Fitchie wrote:

    > > Unlock-DPMLibraryDoor -DPMLibrary $library
    >

    > > The problem is Unlock-DPMLibraryDoor prompts for a Yes or No to continue and
    > > MS DPM Team has not provided a parameter to specify this.
    >
    > Patrick, try this. It may not work--but it really should if the DPM team has
    > done their homework. I don't have the snapin to try it out myself.
    >
    > Unlock-DPMLibraryDoor -DPMLibrary $library -Confirm:$false
    >
    > Let us know how it goes. If this does not work, we really need to push back to
    > that team so that they implement this common powershell convention.
    >
    >
    > --
    > $signature = "Hal Rottenberg, MVP - Admin Frameworks"
    > $projects = @{ title = "Blog Author"; url = "http://halr9000.com" },
    > @{ title = "Co-host"; url = "http://powerscripting.net" },
    > @{ title = "Community Director"; url = "http://PowerShellCommunity.org" },
    > @{ title = "Psi Webmaster"; url = "http://psi-im.org" }
    >

      My System SpecsSystem Spec

  4. #4


    Hal Rottenberg [MVP] Guest

    Re: Pipe Yes or No to cmdlet

    Patrick Fitchie wrote:

    > Hi Hal,
    >
    > Thanks for your response. Unfortunately the DPM team has not included the
    > common convention and does not work.
    I have been told that the DPM team has been made aware of this oversight.
    Perhaps Marco's link will help in the meantime.

    --
    $signature = "Hal Rottenberg, MVP - Admin Frameworks"
    $projects = @{ title = "Blog Author"; url = "http://halr9000.com" },
    @{ title = "Co-host"; url = "http://powerscripting.net" },
    @{ title = "Community Director"; url = "http://PowerShellCommunity.org" },
    @{ title = "Psi Webmaster"; url = "http://psi-im.org" }

      My System SpecsSystem Spec

Pipe Yes or No to cmdlet problems?

Similar Threads
Thread Thread Starter Forum Replies Last Post
Quest AD cmdlet -what is the cmdlet to remove computer object IT Staff PowerShell 2 30 Oct 2008
Pipe a pipe command to a file WB VB Script 2 15 Jul 2008
Invoking Cmdlet Get-Location from cmdlet,cant get Currnt Directory Vikram PowerShell 2 05 Jun 2008
Whether a cmdlet derives from cmdlet or pscmdlet Marco Shaw PowerShell 1 19 Sep 2007
Custom cmdlet suite best practices: pipe .NET objects? ...or XmlDocuments? Michael Herman \(Parallelspace/OpenCanal\) PowerShell 1 07 Apr 2007