INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Update subscription password with powershell

Update subscription password with powershell

(OP)
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...

CODE --> Powershell

$uri = "http://localhost//ReportServer_KESSEL/ReportService2010.asmx?WSDL"
$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:

Quote (Error)


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!

RE: Update subscription password with powershell

(OP)
ok, so I figured out how to use the getSubscriptProperties method, with PowerShell, but I hit another snag. There is no ExtensionSettingwsObj row for Password. So how do I set the password, if there is not setting for password?

here is my current code, that get's the info I need. I was expecting to get the setting for Password, update it with a new password and then use the setSubscriptionProperties to get it set...

CODE --> PowerShell

$uri = "http://localhost//ReportServer/ReportService2010.asmx?WSDL"
$username = 'username'

$ReportServerUriSource = $uri;
$global:ssrs = New-WebServiceProxy -Uri $ReportServerUriSource -UseDefaultCredential;
$type = $ssrs.GetType().Namespace

#Define Object Types for Subscription property call
$ExtensionSettingsDataType = ($type + '.ExtensionSettings')
$ActiveStateDataType = ($type + '.ActiveState')
$ParmValueDataType = ($type + '.ParameterValue')

$ExtensionSettingsObj = New-Object ($ExtensionSettingsDataType)
$ActiveStateObj = New-Object ($ActiveStateDataType)
$ParmValueObj = New-Object ($ParmValueDataType)
$Description = $null
$Status = $null
$EventType = $null
$MatchData = $null
 
$reports = $reporting.listchildren("/", $true) | Where-Object {$_.TypeName -eq "Report"}

foreach ($Report in $Reports) {

    $Subscriptions = $ssrs.ListSubscriptions($report.Path)

    foreach ($Subscription in $Subscriptions) {
        
        foreach ($ParmValueObj in $Subscription.DeliverySettings.ParameterValues) {
            #Write-Host "Subscription Parameter - NAME: $($ParmValueObj.name) Subscription Parameter - VALUE: $($ParmValueObj.Value)"
            if ($ParmValueObj.name -eq "USERNAME") {

                # Write-Host "UserName: $($ParmValueObj.Value)"

                if ($ParmValueObj.Value -eq $username) {
                    
                    Write-Host ""
                    Write-Host "Subscription Name: " $subscription.Report
					Write-Host "SubscriptionID: " $Subscription.SubscriptionID
					Write-Host "DeliveryExtension: " $subscription.DeliverySettings.Extension
					write-host "Field: " $ParmValueObj.name					
					write-host "Value: " $ParmValueObj.value

                    if ($Subscription.IsDataDriven.ToString() -eq "False") {
        
                        #GET SUBSCRIPTION PROPERTIES
                        $SubscriptionProperties = $SSRS.GetSubscriptionProperties($Subscription.SubscriptionID.ToString(),` [ref]$ExtensionSettingsObj, ` [ref]$description, ` [ref]$ActiveStateObj, ` [ref]$status, ` [ref]$eventType, ` [ref]$matchdata, ` [ref]$ParmValueObj)            
        
                        foreach ($ExtensionRow in $ExtensionSettingsObj.ParameterValues){		#Pulls all the ExtensionSettings

			                write-host "ExtensionRow - NAME: $($ExtensionRow.name) ExtensionRow - VALUE: $($ExtensionRow.value)"
                            
                
                            if ($ExtensionRow.name -eq "PASSWORD") {
                                Write-Host "Password Unencrypted..."
                            }			    
		                }                      
                    }
                }
            }
        }        
    }
} 

Does this mean that the password is encrypted and I can't get that setting and in turn, I can't update it?

Thanks!

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close