-------------------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.
> 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" }
Thanks for your response. Unfortunately the DPM team has not included the
common convention and does not work.
Patrick
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
I have been told that the DPM team has been made aware of this oversight.
Perhaps Marco's link will help in the meantime.
Thanks.