Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Pipe Yes or No to cmdlet

4 views
Skip to first unread message

Patrick Fitchie

unread,
Oct 31, 2008, 4:32:00 PM10/31/08
to
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.

Patrick Fitchie

unread,
Oct 31, 2008, 4:33:00 PM10/31/08
to

Patrick Fitchie

unread,
Oct 31, 2008, 4:36:00 PM10/31/08
to
Sorry for the Duplicate Post

Hal Rottenberg [MVP]

unread,
Nov 2, 2008, 10:53:26 AM11/2/08
to
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" }

Patrick Fitchie

unread,
Nov 2, 2008, 2:35:00 PM11/2/08
to
Hi Hal,

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

Patrick

Marco Shaw [MVP]

unread,
Nov 2, 2008, 2:41:35 PM11/2/08
to
Patrick Fitchie wrote:
> Hi Hal,
>
> Thanks for your response. Unfortunately the DPM team has not included the
> common convention and does not work.

A possible workaround:
http://groups.google.com/group/microsoft.public.dataprotectionmanager/browse_thread/thread/df4735f73d1e7d8/3bf7177389e7824f?lnk=gst&q=confirm#3bf7177389e7824f

Marco

--
*Microsoft MVP - Windows Server - Admin Frameworks
https://mvp.support.microsoft.com/profile/Marco.Shaw
*PowerShell Co-Community Director - http://www.powershellcommunity.org
*Blog - http://marcoshaw.blogspot.com

Hal Rottenberg [MVP]

unread,
Nov 3, 2008, 8:07:29 AM11/3/08
to
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.

Patrick Fitchie

unread,
Nov 3, 2008, 11:45:01 AM11/3/08
to
Excellent Macro, $ConfirmPreference = 'none' worked like a charm

Thanks.

0 new messages