Kawika Moss
Programmer
When you have to update your AD credentials, you then have to go in and update your password for all the datasources and subscriptions, in SSRS, that are owned by you.
I'm trying to automate this with a PS script. What I have so far is...
And the error I'm getting is:
I got most of this script from a script that was already out there, located at Manage Subscriptions
Does anyone have an idea of how to do this, this would save hours of time...btw, we are using 2008R2.
Thanks!
I'm trying to automate this with a PS script. What I have so far is...
Code:
$uri = "[URL unfurl="true"]http://localhost//ReportServer_KESSEL/ReportService2010.asmx?WSDL"[/URL]
$password = 'newPassword'
$username = 'kawika.moss'
$UpdatePassword = $true
$reporting = New-WebServiceProxy -uri $uri -UseDefaultCredential -namespace "ReportingService2010" -class Reporting
$reporting.url = $uri #Makes sure URL is set correctly after call; sometimes this flips to a default URL
$details = new-object -TypeName System.String -argumentList ("")
##Initialize Variable Types required for GetSubscription call
$ExtensionSettings = new-object -TypeName ReportingService2010.ExtensionSettings
$ExtensionRow = new-object -TypeName ReportingService2010.ExtensionSettings
$Description = new-object -TypeName System.String -argumentList ("")
$Active = new-object -TypeName ReportingService2010.ActiveState
$Status = new-object -TypeName System.String -argumentList ("")
$EventType = new-object -TypeName System.String -argumentList ("")
$MatchData = new-object -TypeName System.String -argumentList ("")
$Parameters = new-object -TypeName ReportingService2010.ParameterValue
# $ExtensionSettings = ''
# $ExtensionRow = ''
# $Description = ''
# $Active = ''
# $Status = ''
# $EventType = ''
# $MatchData = ''
# $Parameters = ''
$DataRetrievalPlan = new-object -TypeName ReportingService2010.DataRetrievalPlan
$ParametersValue = new-object -TypeName ReportingService2010.ParameterValue
$subscriptions= new-object -TypeName ReportingService2010.Subscription
$subscription= new-object -TypeName ReportingService2010.Subscription
$ExtensionPassword = new-object -TypeName ReportingService2010.ParameterValue
$reports = $reporting.listchildren("/", $true) | Where-Object {$_.TypeName -eq "Report"}
# $reports
$ExtensionPassword.Name = "PASSWORD"
$ExtensionPassword.value = $password
#Write-host $dataSource.Item.UserName
#$subscriptions += $rs2010.ListSubscriptions("/"); # use "/" for default native mode site
foreach ($report in $reports){
$subscriptions = $reporting.ListSubscriptions($report.Path)
#$subscriptions
foreach ($subscription in $subscriptions){
$ReportSubscriptionID = [String]$subscription.SubscriptionID #Sets a variable to the SubscriptionID Value
#$ReportSubscriptionID
If ($ReportSubscriptionID){
##Looks through the extensions stored within the subscription for Username/Password
foreach ($ParameterValue in $subscription.DeliverySettings.ParameterValues){
If ($ParameterValue.name -eq "USERNAME"){ #Finds the username parameter
write-host $ParametersValue.Value
If ($ParameterValue.value -eq $username){ #Checks if this is the username we are looking for
Write-Host " Subscription Name: " $subscription.Report
#Write-Host " SubscriptionID: " $Subscription.SubscriptionID
Write-Host " DeliveryExtension: " $subscription.DeliverySettings.Extension
write-host " Field: " $ParameterValue.name
#write-host " Label: " $ParameterValue.label ##Not used
write-host " Value: " $ParameterValue.value
#Sets the new password
$PasswordUpdated = $false
If ($UpdatePassword -eq $true){
$details = ""
#Gets the subscription Properties prior to updating the password
$details = $reporting.GetSubscriptionProperties($Subscription.SubscriptionID, [REF]$ExtensionSettings, [REF]$Description, [REF]$Active, [REF]$Status, [REF]$EventType, [REF]$MatchData, [REF]$ParametersValue)
$i=0 #initialize counter variable
foreach ($ExtensionRow in $ExtensionSettings.ParameterValues){ #Pulls all the ExtensionSettings
write-host " ExtensionRow: " $ExtensionRow.name
write-host " ExtensionRow.Values: " $ExtensionRow.value
If ($ExtensionRow.name -eq "PASSWORD"){ #Checks to see if PASSWORD is unencrypted and available to pull
Write-Host "updating password..."
#$ExtensionRow.value = $password #Sets the value
Write-Host "!! WARNING: Unencrypted password retrieved" -ForegroundColor "Red"
$PasswordUpdated = $true
break #Exits for loop -- password updated, now to commit change
}
$i++ #Increments counter
If ($ExtensionSettings.ParameterValues.count -eq $i){ #Determines if this is the final iteration and whether the password field was found
$ExtensionSettings.ParameterValues += $ExtensionPassword
$PasswordUpdated = $true
break #Exits for loop -- member group added and set
#}
}
}
# #Sets the Subscription settings -- with the new Password
# If ($PasswordUpdated -eq $true){ #Password has actually been updated
# $details = $reporting.SetSubscriptionProperties($ReportSubscriptionID, $ExtensionSettings, $Description, $EventType, $MatchData, $ParametersValue)
# }
# ELSE{
# Write-Host " ERROR: PASSWORD NOT UPDATED" -ForegroundColor "Red"
# }
}
}
}
}
}
}
}
And the error I'm getting is:
Error said:Exception calling "GetSubscriptionProperties" with "8" argument(s): "Cannot convert the "System.Management.Automation.PSReference`1[ReportingService2010.ExtensionSettings]" value of type
"System.Management.Automation.PSReference`1[[ReportingService2010.ExtensionSettings, dnxukfbc, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]]" to type
"ReportingService2010.ExtensionSettings"."
At C:\Users\kawika.moss\Documents\PowershellScripting\TestUpdateSubscriptionPassword.ps1:76 char:11
+ $details = $reporting.GetSubscriptionProperties($Subscription.Subscrip ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: ) [], MethodInvocationException
+ FullyQualifiedErrorId : PSInvalidCastException
I got most of this script from a script that was already out there, located at Manage Subscriptions
Does anyone have an idea of how to do this, this would save hours of time...btw, we are using 2008R2.
Thanks!