Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - Pipe Yes or No to cmdlet

Reply
 
Old 10-31-2008   #1 (permalink)
Patrick Fitchie


 
 

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
Old 11-02-2008   #2 (permalink)
Hal Rottenberg [MVP]


 
 

Re: Pipe Yes or No to cmdlet

Patrick Fitchie wrote:
Quote:

> Unlock-DPMLibraryDoor -DPMLibrary $library
Quote:

> 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
Old 11-02-2008   #3 (permalink)
Patrick Fitchie


 
 

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:
Quote:

> Patrick Fitchie wrote:
Quote:

> > Unlock-DPMLibraryDoor -DPMLibrary $library
>
Quote:

> > 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
Old 11-03-2008   #4 (permalink)
Hal Rottenberg [MVP]


 
 

Re: Pipe Yes or No to cmdlet

Patrick Fitchie wrote:
Quote:

> 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
Reply

Thread Tools


Similar Threads
Thread Forum
Quest AD cmdlet -what is the cmdlet to remove computer object PowerShell
Pipe a pipe command to a file VB Script
Invoking Cmdlet Get-Location from cmdlet,cant get Currnt Directory PowerShell
Whether a cmdlet derives from cmdlet or pscmdlet PowerShell
Custom cmdlet suite best practices: pipe .NET objects? ...or XmlDocuments? PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46