diff --git a/ReportingServicesTools/Functions/CatalogItems/Copy-RsSubscription.ps1 b/ReportingServicesTools/Functions/CatalogItems/Copy-RsSubscription.ps1
new file mode 100644
index 00000000..136fe5b2
--- /dev/null
+++ b/ReportingServicesTools/Functions/CatalogItems/Copy-RsSubscription.ps1
@@ -0,0 +1,153 @@
+# Copyright (c) 2016 Microsoft Corporation. All Rights Reserved.
+# Licensed under the MIT License (MIT)
+
+function Copy-RsSubscription
+{
+ <#
+ .SYNOPSIS
+ This script creates a new reporting subscription using an existing subscription.
+
+ .DESCRIPTION
+ This script creates a new reporting subscription based on the info of an existing subscription (retrieved using Get-RsSubscription).
+ You can choose a specific report or pass a folder. When using a folder, the report must have the same name.
+ NOTE: A new subscriptionId will be generated.
+
+ .PARAMETER RsItem
+ Specify the path to the destination report. Can't be used with -RsFolder parameter.
+
+ .PARAMETER RsFolder
+ Specify the folder where the destination reports exists. Can't be used with -RsItem parameter.
+
+ .PARAMETER Subscription
+ A object with all subscritpion configurations. The default output of Get-RsSubscription. You must piping it to this command.
+
+ .PARAMETER ReportServerUri
+ Specify the Report Server URL to your SQL Server Reporting Services Instance.
+ Use the "Connect-RsReportServer" function to set/update a default value.
+
+ .PARAMETER Credential
+ Specify the credentials to use when connecting to the Report Server.
+ Use the "Connect-RsReportServer" function to set/update a default value.
+
+ .PARAMETER Proxy
+ Report server proxy to use.
+ Use "New-RsWebServiceProxy" to generate a proxy object for reuse.
+ Useful when repeatedly having to connect to multiple different Report Server.
+
+ .EXAMPLE
+ Get-RsSubscription -ReportServerUri 'http://localhost/ReportServer_sql14' -RsItem '/path/to/my/oldReport' | Copy-RsSubscription -ReportServerUri 'http://remote-machine:8080/reportserver_sql16' -RsItem '/path/to/newReport'
+
+ Description
+ -----------
+ This command will establish a connection to the Report Server located at http://localhost/ReportServer_sql14 using current user's credentials get all subscriptions from report '/path/to/my/oldReport'
+ and pipe the results to Copy-RsSubscription which will create a new subscription on report '/path/to/newReport' located at Report Server 'http://remote-machine:8080/reportserver_sql16'
+
+ .EXAMPLE
+ Get-RsSubscription -ReportServerUri 'http://localhost/ReportServer_sql14' -RsItem '/path/to/my/oldReport' | Copy-RsSubscription -ReportServerUri 'http://remote-machine:8080/reportserver_sql16' -RsFolder '/New Folder'
+
+ Description
+ -----------
+ This command will establish a connection to the Report Server located at http://localhost/ReportServer_sql14 using current user's credentials get all subscriptions from report '/path/to/my/oldReport'
+ and pipe the results to Copy-RsSubscription which will create a new subscription on each report that exists with the same name on the destination folder '/New Folder' located at Report Server 'http://remote-machine:8080/reportserver_sql16'
+
+ .EXAMPLE
+ $paths = Get-RsCatalogItems -ReportServerUri 'http://localhost/ReportServer_sql14' -RsFolder /Origin | Where-Object TypeName -eq "Report" | Select-Object -ExpandProperty Path
+ Get-RsSubscription -ReportServerUri 'http://localhost/ReportServer_sql14' RsItem $paths | Copy-RsSubscription -ReportServerUri 'http://remote-machine:8080/reportserver_sql16' -RsFolder '/New Folder'
+
+ Description
+ -----------
+ This command will establish a connection to the Report Server located at http://localhost/ReportServer_sql14 using current user's credentials get all the paths from all reports at '/Origin' folder.
+ Then it uses the $paths variable to get all existing subscriptions and pipe the results to Copy-RsSubscription which will create a new subscription on each report that exists with the same name on the destination folder '/New Folder' located at Report Server 'http://remote-machine:8080/reportserver_sql16'
+ #>
+
+ [cmdletbinding(SupportsShouldProcess = $true, ConfirmImpact = 'Medium')]
+ param
+ (
+ [string]
+ $ReportServerUri,
+
+ [System.Management.Automation.PSCredential]
+ $Credential,
+
+ $Proxy,
+
+ [Alias('ReportPath','ItemPath','Path')]
+ [Parameter(ParameterSetName='Report', Mandatory=$True)]
+ [string]
+ $RsItem,
+
+ [Alias('Folder')]
+ [Parameter(ParameterSetName='Folder', Mandatory=$True)]
+ [string]
+ $RsFolder,
+
+ [Parameter(Mandatory = $True, ValueFromPipeline=$true)]
+ [object[]]
+ $Subscription
+ )
+ Begin
+ {
+ $Proxy = New-RsWebServiceProxyHelper -BoundParameters $PSBoundParameters
+ }
+ Process
+ {
+ #region Input Validation
+ $itemNullOrEmpty = [System.String]::IsNullOrEmpty($RsItem)
+ $folderNullOrEmpty = [System.String]::IsNullOrEmpty($RsFolder)
+ if ($itemNullOrEmpty -and $folderNullOrEmpty)
+ {
+ throw 'No folder or report path was specified! You need to specify -RsFolder or -RsItem.'
+ }
+ elseif (!$itemNullOrEmpty -and !$folderNullOrEmpty)
+ {
+ throw 'Both folder and report path were specified! Please specify either -RsFolder or -RsItem.'
+ }
+ #endregion Input Validation
+
+ try
+ {
+ foreach ($sub in $Subscription)
+ {
+ if ($RsFolder)
+ {
+ $RsItem = "$RsFolder/$($sub.Report)"
+ }
+ else
+ {
+ $RsFolder = (Split-Path $RsItem -Parent).Replace("\", "/")
+ }
+
+ Write-Verbose "Validating if target report exists..."
+ if (((Get-RsFolderContent -Proxy $Proxy -RsFolder $RsFolder | Where-Object Path -eq $RsItem).Count) -eq 0)
+ {
+ Write-Warning "Can't find the report $RsItem. Skipping."
+ Continue
+ }
+
+ if ($PSCmdlet.ShouldProcess($RsItem, "Creating new subscription"))
+ {
+ Write-Verbose "Creating Subscription..."
+ if ($subscription.IsDataDriven)
+ {
+ $subscriptionId = $Proxy.CreateDataDrivenSubscription($RsItem, $sub.DeliverySettings, $sub.DataRetrievalPlan, $sub.Description, $sub.EventType, $sub.MatchData, $sub.Values)
+ }
+ else
+ {
+ $subscriptionId = $Proxy.CreateSubscription($RsItem, $sub.DeliverySettings, $sub.Description, $sub.EventType, $sub.MatchData, $sub.Values)
+ }
+
+ [pscustomobject]@{
+ NewSubscriptionId = $subscriptionId
+ DestinationReport = $RsItem
+ OriginalReport = $sub.Path
+ }
+ Write-Verbose "Subscription created successfully! Generated subscriptionId: $subscriptionId"
+ }
+ }
+ }
+ catch
+ {
+ throw (New-Object System.Exception("Exception occurred while creating subscription! $($_.Exception.Message)", $_.Exception))
+ }
+ }
+}
diff --git a/ReportingServicesTools/Functions/CatalogItems/Get-RsSubscription.ps1 b/ReportingServicesTools/Functions/CatalogItems/Get-RsSubscription.ps1
index 06e7b654..996f85e6 100644
--- a/ReportingServicesTools/Functions/CatalogItems/Get-RsSubscription.ps1
+++ b/ReportingServicesTools/Functions/CatalogItems/Get-RsSubscription.ps1
@@ -6,13 +6,13 @@ function Get-RsSubscription
<#
.SYNOPSIS
This script retrieves information about subscriptions for a report.
-
+
.DESCRIPTION
This script retrieves information about subscriptions for a report.
-
- .PARAMETER Path
+
+ .PARAMETER RsItem
Specify the path to the report.
-
+
.PARAMETER ReportServerUri
Specify the Report Server URL to your SQL Server Reporting Services Instance.
Use the "Connect-RsReportServer" function to set/update a default value.
@@ -21,24 +21,31 @@ function Get-RsSubscription
The version of the API to use, 2010 by default. Sepcifiy '2005' if you need
to query a Sql Server Reporting Service Instance running a version prior to
SQL Server 2008 R2.
-
+
.PARAMETER Credential
Specify the credentials to use when connecting to the Report Server.
Use the "Connect-RsReportServer" function to set/update a default value.
-
+
.PARAMETER Proxy
Report server proxy to use.
Use "New-RsWebServiceProxy" to generate a proxy object for reuse.
Useful when repeatedly having to connect to multiple different Report Server.
-
+
.EXAMPLE
- Get-RsSubscription -Path '/path/to/my/report'
+ Get-RsSubscription -RsItem '/path/to/my/report'
Description
-----------
This command will establish a connection to the Report Server located at http://localhost/reportserver using current user's credentials and retrieve details of subscriptions found at '/path/to/my/report'.
-
+
+ .EXAMPLE
+ Get-RsSubscription -ReportServerUri 'http://remote-machine:8080/reportserver_sql16' -RsItem '/path/to/my/report'
+ Description
+ -----------
+ This command will establish a connection to the Report Server located at http://remote-machine:8080/reportserver_sql16 using current user's credentials and retrieve details of subscriptions found at '/path/to/my/report'.
+
.EXAMPLE
- Get-RsSubscription -ReportServerUri 'http://remote-machine:8080/reportserver_sql16' -Path '/path/to/my/report'
+ $rsProxy = New-RsWebServiceProxy -ReportServerUri 'http://remote-machine:8080/reportserver_sql16'
+ Get-RsSubscription -Proxy $rsProxy -RsItem '/path/to/my/report'
Description
-----------
This command will establish a connection to the Report Server located at http://remote-machine:8080/reportserver_sql16 using current user's credentials and retrieve details of subscriptions found at '/path/to/my/report'.
@@ -47,41 +54,41 @@ function Get-RsSubscription
[cmdletbinding()]
param
(
+ [Alias('Path')]
[Parameter(Mandatory = $True, ValueFromPipeline = $true)]
[string[]]
- $Path,
-
+ $RsItem,
+
[string]
$ReportServerUri,
[ValidateSet('2005','2006','2010')]
[string]
$ApiVersion = '2010',
-
+
[System.Management.Automation.PSCredential]
$Credential,
-
+
$Proxy
)
-
Begin
{
$Proxy = New-RsWebServiceProxyHelper -BoundParameters $PSBoundParameters
}
Process
{
- foreach ($item in $Path)
+ foreach ($item in $RsItem)
{
try
{
Write-Verbose "Retrieving subscriptions contents..."
-
- if ($Proxy.Url -match 'ReportService2005.asmx')
+
+ if ($Proxy.Url -match 'ReportService2005.asmx')
{
if ($item -eq '/') { $item = $null }
$subscriptions = $Proxy.ListSubscriptions($Item,$null)
- }
- else
+ }
+ else
{
$subscriptions = $Proxy.ListSubscriptions($Item)
}
@@ -92,8 +99,8 @@ function Get-RsSubscription
$DataRetrievalPlanDataType = "$namespace.DataRetrievalPlan"
$ExtensionSettingsDataType = "$namespace.ExtensionSettings"
$ActiveStateDataType = "$namespace.ActiveState"
-
- foreach ($subscription in $subscriptions)
+
+ foreach ($subscription in $subscriptions)
{
$extSettings = $null
$DataRetrievalPlan = $null
@@ -107,7 +114,7 @@ function Get-RsSubscription
try
{
- Write-Verbose "Retrieving subscription properties for $($subscription.SubscriptionID)"
+ Write-Verbose "Retrieving subscription properties for $($subscription.SubscriptionID)..."
if ($subscription.IsDataDriven)
{
@@ -117,7 +124,9 @@ function Get-RsSubscription
{
$null = $Proxy.GetSubscriptionProperties($subscription.SubscriptionID, [ref]$extSettings, [ref]$desc, [ref]$active, [ref]$status, [ref]$eventType, [ref]$matchData, [ref]$values)
}
-
+
+ Write-Verbose "Subscription properties for $($subscription.SubscriptionID) retrieved successfully!"
+
#Set ExtensionSetting/s
$ExtensionSettings = New-Object $ExtensionSettingsDataType
$ExtensionSettings.Extension = $subscription.DeliverySettings.Extension
@@ -135,7 +144,7 @@ function Get-RsSubscription
$ActiveState.InvalidParameterValueSpecified = $subscription.Active.InvalidParameterValueSpecified
$ActiveState.UnknownReportParameter = $subscription.Active.UnknownReportParameter
$ActiveState.UnknownReportParameterSpecified = $subscription.Active.UnknownReportParameterSpecified
-
+
$Result = @{
SubscriptionID = $subscription.SubscriptionID
Owner = $subscription.Owner
@@ -155,9 +164,10 @@ function Get-RsSubscription
MatchData = $matchData
Values = $values
}
- if ($subscription.IsDataDriven)
- {
- $Result.Add('DataRetrievalPlan',$DataRetrievalPlan)
+
+ if ($subscription.IsDataDriven)
+ {
+ $Result.Add('DataRetrievalPlan',$DataRetrievalPlan)
}
[pscustomobject]$Result
diff --git a/ReportingServicesTools/Functions/CatalogItems/Import-RsSubscriptionXml.ps1 b/ReportingServicesTools/Functions/CatalogItems/Import-RsSubscriptionXml.ps1
index 42164360..d45d774e 100644
--- a/ReportingServicesTools/Functions/CatalogItems/Import-RsSubscriptionXml.ps1
+++ b/ReportingServicesTools/Functions/CatalogItems/Import-RsSubscriptionXml.ps1
@@ -5,24 +5,24 @@ function Import-RsSubscriptionXml {
<#
.SYNOPSIS
This script imports a subscription that has been exported e.g via Get-RsSubscription | Export-RsSubscriptionXml .\somepath.xml
-
+
.DESCRIPTION
This script imports a subscription and rebuilds the SRSS specific properties so that the resultant object will be accepted by Set-RsSubscription.
This is useful if you need to store your subscription configs in a file (e.g to add to source control) and then later want to use that file to
recreate your subscriptions.
-
+
.PARAMETER Path
The path to the XML file that contains the exported subscription.
This is typically a file created by executing Get-RsSubscription | Export-RsSubscriptionXml .\somepath.xml
-
+
.PARAMETER ReportServerUri
Specify the Report Server URL to your SQL Server Reporting Services Instance.
Use the "Connect-RsReportServer" function to set/update a default value.
-
+
.PARAMETER Credential
Specify the credentials to use when connecting to the Report Server.
Use the "Connect-RsReportServer" function to set/update a default value.
-
+
.PARAMETER Proxy
Report server proxy to use.
Use "New-RsWebServiceProxy" to generate a proxy object for reuse.
@@ -44,7 +44,7 @@ function Import-RsSubscriptionXml {
This command will import the subscriptions contained in .\MySubscriptions.xml, recreate any SRSS specific properties
and pipe the results to Set-RsSubscription which will add them to the /Example/Report report.
#>
-
+
[cmdletbinding()]
param(
[Parameter(Mandatory=$True,Position=0)]
@@ -53,18 +53,20 @@ function Import-RsSubscriptionXml {
[string]
$ReportServerUri,
-
+
[System.Management.Automation.PSCredential]
$Credential,
-
+
$Proxy
)
- Begin {
+ Begin
+ {
$Proxy = New-RsWebServiceProxyHelper -BoundParameters $PSBoundParameters
$Namespace = $Proxy.GetType().NameSpace
}
- Process {
+ Process
+ {
Write-Verbose "Importing Subscription from $Path..."
$Subscription = Import-Clixml $Path
@@ -72,37 +74,35 @@ function Import-RsSubscriptionXml {
{
#Recreate .DeliverySettings properties as valid SRSS object type
$ParameterValues = @()
-
+
$Sub.DeliverySettings.ParameterValues | ForEach-Object {
-
- if ($_.Name)
+ if ($_.Name)
{
$ParameterValues = $ParameterValues + (New-Object "$Namespace.ParameterValue" -Property @{ Name = $_.Name; Value = $_.Value })
}
- elseif ($_.ParameterName)
+ elseif ($_.ParameterName)
{
$ParameterValues = $ParameterValues + (New-Object "$Namespace.ParameterFieldReference" -Property @{ ParameterName = $_.ParameterName; FieldAlias = $_.FieldAlias })
}
}
-
- $DeliverySettings = @{
+
+ $DeliverySettings = @{
Extension = $Sub.DeliverySettings.Extension
ParameterValues = $ParameterValues
}
- $Sub.DeliverySettings = (New-Object "$Namespace.ExtensionSettings" -Property $DeliverySettings)
-
-
+ $Sub.DeliverySettings = (New-Object "$Namespace.ExtensionSettings" -Property $DeliverySettings)
+
#Recreate .Values property as valid SRSS object type
$Values = @()
$Sub.Values | ForEach-Object {
- if ($_.Name)
+ if ($_.Name)
{
$Values = $Values + (New-Object "$Namespace.ParameterValue" -Property @{ Name = $_.Name; Value = $_.Value })
}
- elseif ($_.ParameterName)
+ elseif ($_.ParameterName)
{
$Values = $Values + (New-Object "$Namespace.ParameterFieldReference" -Property @{ ParameterName = $_.ParameterName; FieldAlias = $_.FieldAlias })
}
@@ -118,10 +118,10 @@ function Import-RsSubscriptionXml {
$Sub.DataRetrievalPlan.DataSet.Fields | ForEach-Object {
$DataSetDefinitionFields = $DataSetDefinitionFields + (New-Object "$Namespace.Field" -Property @{ Alias = $_.Alias; Name = $_.Name })
}
-
+
$DataSetDefinition = New-Object "$Namespace.DataSetDefinition"
$DataSetDefinition.Fields = $DataSetDefinitionFields
-
+
$DataSetDefinition.Query = New-Object "$Namespace.QueryDefinition"
$DataSetDefinition.Query.CommandType = $sub.DataRetrievalPlan.DataSet.Query.CommandType
diff --git a/ReportingServicesTools/Functions/CatalogItems/New-RsSubscription.ps1 b/ReportingServicesTools/Functions/CatalogItems/New-RsSubscription.ps1
index 40b775f5..ec902e62 100644
--- a/ReportingServicesTools/Functions/CatalogItems/New-RsSubscription.ps1
+++ b/ReportingServicesTools/Functions/CatalogItems/New-RsSubscription.ps1
@@ -1,23 +1,24 @@
# Copyright (c) 2016 Microsoft Corporation. All Rights Reserved.
# Licensed under the MIT License (MIT)
-function New-RsSubscription {
+function New-RsSubscription
+{
<#
.SYNOPSIS
This script creates a new reporting subscription.
-
+
.DESCRIPTION
This script creates a new reporting subscription based on the parameters provided. NOTE: A new subscriptionId will be generated.
-
- .PARAMETER Path
+
+ .PARAMETER RsItem
Specify the path to the destination report.
-
+
.PARAMETER ReportServerUri
Specify the Report Server URL to your SQL Server Reporting Services Instance. Use the "Connect-RsReportServer" function to set/update a default value.
-
+
.PARAMETER Credential
Specify the credentials to use when connecting to the Report Server. Use the "Connect-RsReportServer" function to set/update a default value.
-
+
.PARAMETER Proxy
Report server proxy to use. Use "New-RsWebServiceProxy" to generate a proxy object for reuse. Useful when repeatedly having to connect to multiple different Report Server.
@@ -28,82 +29,127 @@ function New-RsSubscription {
The event which triggers the schedule. Specify either 'TimedSubscription' or 'SnapshotUpdated'.
Default: 'TimedSubscription'.
- .PARAMETER Destination
- The delivery destination. Specify either 'FileShare', 'Email' or (not yet supported) 'DocumentLibrary'.
+ .PARAMETER DeliveryMethod
+ The delivery method. Specify either 'FileShare' or 'Email'.
.PARAMETER Schedule
Either a shared schedule ID or an XML block representing the desired schedule. You can use "New-RsScheduleXML" function to generate the required XML.
Required if -EventType 'TimedSubscription' has been used.
+ .PARAMETER RenderFormat
+ Specify the output format of the report. Must be one of 'PDF','MHTML','IMAGE','CSV','XML','EXCELOPENXML','ATOM','PPTX','WORDOPENXML'
+
.PARAMETER To
- Use with -Destination 'Email' to specify email addresses.
+ Use with -DeliveryMethod 'Email' to specify email addresses.
.PARAMETER CC
- Use with -Destination 'Email' to specify CC email addresses.
+ Use with -DeliveryMethod 'Email' to specify CC email addresses.
.PARAMETER BCC
- Use with -Destination 'Email' to specify BCC email addresses.
+ Use with -DeliveryMethod 'Email' to specify BCC email addresses.
- .PARAMETER ExcludeReport
- Use with -Destination 'Email' to exclude the report from the email.
-
- .PARAMETER Subject
- Use with -Destination 'Email' to specify the subject line of the email.
+ .PARAMETER ReplyTo
+ Use with -DeliveryMethod 'Email' to specify ReplyTo email address.
- .PARAMETER DestinationPath
- Use with -Destination 'FileShare' to specify the destination location of the generated report. Must be a UNC path.
+ .PARAMETER Subject
+ Use with -DeliveryMethod 'Email' to specify the subject line of the email.
- .PARAMETER FileName
- Use with -Destination 'FileShare' to specify the filename of the generated report.
+ .PARAMETER ExcludeReport
+ Use with -DeliveryMethod 'Email' to exclude the report from the email.
- .PARAMETER RenderFormat
- Specify the output format of the report. Must be one of 'PDF','MHTML','IMAGE','CSV','XML','EXCELOPENXML','ATOM','PPTX','WORDOPENXML'
-
.PARAMETER ExcludeLink
- Use with -Destination 'Email' to exclude a link back to the report from the email.
-
+ Use with -DeliveryMethod 'Email' to exclude a link back to the report from the email.
+
.PARAMETER Priority
- Use with -Destination 'Email' to set the priority with which the e-mail message is sent. Valid values are LOW, NORMAL, and HIGH. The default value is NORMAL.
-
+ Use with -DeliveryMethod 'Email' to set the priority with which the e-mail message is sent. Valid values are LOW, NORMAL, and HIGH. The default value is NORMAL.
+
+ .PARAMETER Comment
+ Use with -DeliveryMethod 'Email' to specify a comment in the email.
+
+ .PARAMETER FileSharePath
+ Use with -DeliveryMethod 'FileShare' to specify the destination location of the generated report. Must be a UNC path.
+
+ .PARAMETER FileShareCredentials
+ Use with -DeliveryMethod 'FileShare' to specify the credentials to use when writing file to fileshare. If no credentials are specified, then Execution Account or Service Account credentials are used.
+
+ .PARAMETER FileName
+ Use with -DeliveryMethod 'FileShare' to specify the filename of the generated report.
+
+ .PARAMETER FileWriteMode
+ Use with -DeliveryMethod 'FileShare' to specify the filename of the generated report.
+
.EXAMPLE
- New-RsSubscription -ReportServerUri 'http://localhost/ReportServer' -Path '/path/to/my/Report' -Description 'Daily to folder' -Destination 'FileShare' -Schedule (New-RsScheduleXML -Daily 1) -DestinationPath '\\Myserver\folder' -FileName 'MyReport' -RenderFormat 'PDF'
+ New-RsSubscription -RsItem '/path/to/my/Report' -Description 'Daily to folder' -RenderFormat 'PDF' -Schedule (New-RsScheduleXML -Daily 1) -DeliveryMethod 'FileShare' -FileSharePath '\\Myserver\folder' -FileName 'MyReport' -FileWriteMode Overwrite
Description
-----------
- This command will establish a connection to the Report Server located at http://localhost/ReportServer using current user's credentials and create a subscription for report '/path/to/my/Report'
- that outputs the report in PDF format to the specified file share path and name on a daily basis at the current time.
+ This command will establish a connection to the Report Server located at http://localhost/ReportServer using current user's credentials and create a subscription for report '/path/to/my/Report' that outputs and overwrites the report in PDF format to the specified file share path and name on a daily basis at the current time.
.EXAMPLE
- New-RsSubscription -ReportServerUri 'http://localhost/ReportServer' -Path '/path/to/my/Report' -Description 'Fortnightly by email' -Destination 'Email' -Schedule (New-RsScheduleXML -Weekly -Interval 2 -DaysOfWeek Saturday) -Subject 'Fortnightly report' -To 'test@someaddress.com' -RenderFormat 'WordOpenXML'
+ New-RsSubscription -RsItem '/path/to/my/Report' -Description 'Daily to folder' -RenderFormat 'PDF' -Schedule (New-RsScheduleXML -Daily 1) -DeliveryMethod 'FileShare' -FileSharePath '\\Myserver\folder' -FileName 'MyReport' -FileWriteMode None
Description
-----------
- This command will establish a connection to the Report Server located at http://localhost/ReportServer using current user's credentials and create a subscription for report '/path/to/my/Report'
- that outputs the report in Word format by email to the specified recipient every other Saturday at the current time.
+ This command will establish a connection to the Report Server located at http://localhost/ReportServer using current user's credentials and create a subscription for report '/path/to/my/Report' that outputs the report in PDF format to the specified file share path and name (as long as another file with same name does NOT exists) on a daily basis at the current time.
+
+ .EXAMPLE
+ New-RsSubscription -RsItem '/path/to/my/Report' -Description 'Daily to folder' -RenderFormat 'PDF' -Schedule (New-RsScheduleXML -Daily 1) -DeliveryMethod 'FileShare' -FileSharePath '\\Myserver\folder' -FileName 'MyReport' -FileWriteMode AutoIncrement
+
+ Description
+ -----------
+ This command will establish a connection to the Report Server located at http://localhost/ReportServer using current user's credentials and create a subscription for report '/path/to/my/Report' that outputs the report in PDF format to the specified file share path and name (to a new file) on a daily basis at the current time.
+
+ .EXAMPLE
+ New-RsSubscription -RsItem '/path/to/my/Report' -Description 'Daily to folder' -RenderFormat 'PDF' -Schedule (New-RsScheduleXML -Daily 1) -DeliveryMethod 'FileShare' -FileSharePath '\\Myserver\folder' -FileName 'MyReport' -FileWriteMode Overwrite -FileShareCredentials (Get-Credential)
+
+ Description
+ -----------
+ This command will establish a connection to the Report Server located at http://localhost/ReportServer using current user's credentials and create a subscription for report '/path/to/my/Report' that outputs and overwrites the report in PDF format to the specified file share path and name using the specified $FileShareCredentials on a daily basis at the current time.
+
+ .EXAMPLE
+ New-RsSubscription -RsItem '/path/to/my/Report' -Description 'Fortnightly by email' -RenderFormat 'WordOpenXML' -Schedule (New-RsScheduleXML -Weekly -Interval 2 -DaysOfWeek Saturday) -DeliveryMethod 'Email' -Subject 'Fortnightly report' -To 'test@someaddress.com'
+
+ Description
+ -----------
+ This command will establish a connection to the Report Server located at http://localhost/ReportServer using current user's credentials and create a subscription for report '/path/to/my/Report' that outputs the report in Word format by email to the specified recipient every other Saturday at the current time.
.EXAMPLE
- New-RsSubscription -ReportServerUri 'http://localhost/ReportServer' -Path '/path/to/my/Report' -Description "One minute from now" -Destination 'Email' -Schedule (New-RsScheduleXML -Once -StartDate [datetime]::Now.AddMinutes(1)) -Subject 'One minute from now' -To 'Christopher.Wren@example.com' -RenderFormat 'MHTML' -Priority 'HIGH' -ExcludeLink
-
+ New-RsSubscription -RsItem '/path/to/my/Report' -Description "One minute from now" -RenderFormat 'MHTML' -Schedule (New-RsScheduleXML -Once -StartDate [datetime]::Now.AddMinutes(1)) -DeliveryMethod 'Email' -Subject 'One minute from now' -To 'Christopher.Wren@example.com' -Priority 'HIGH' -ExcludeLink -Comment 'Check this report out!'
+
+ Description
+ -----------
+ This command will establish a connection to the Report Server located at http://localhost/ReportServer using current user's credentials and create a subscription for report '/path/to/my/Report' that outputs the report in MHTML format by email to the specified recipient one minute from now, with HIGH priority, without a link back to the report and a comment saying 'Check this report out'
+
+ .EXAMPLE
+ New-RsSubscription -ReportServerUri 'http://myserver/ReportServer' ...
+
+ Description
+ -----------
+ This command will establish a connection to the Report Server located at http://myserver/ReportServer using current user's credentials and create a subscription based on other parameters specified.
+
+ .EXAMPLE
+ $rsProxy = New-RsWebServiceProxy -ReportServerUri 'http://myserver/ReportServer'
+ New-RsSubscription -Proxy $rsProxy ...
+
Description
-----------
- This command will establish a connection to the Report Server located at http://localhost/ReportServer using current user's credentials and create a subscription for report '/path/to/my/Report'
- that outputs the report in MHTML format by email to the specified recipient one minute from now, with HIGH priority and without a link back to the report
+ This command will establish a connection to the Report Server located at http://myserver/ReportServer using current user's credentials and create a subscription based on other parameters specified.
#>
- [cmdletbinding(SupportsShouldProcess = $true, ConfirmImpact = 'Medium',DefaultParameterSetName='FileShare')]
+ [cmdletbinding(SupportsShouldProcess = $true, ConfirmImpact = 'Medium', DefaultParameterSetName='FileShare')]
param(
[string]
$ReportServerUri,
-
+
[System.Management.Automation.PSCredential]
$Credential,
$Proxy,
- [Alias('ReportPath','ItemPath')]
+ [Alias('ReportPath','ItemPath','Path')]
[Parameter(Mandatory=$True)]
[string]
- $Path,
+ $RsItem,
[string]
$Description,
@@ -113,13 +159,18 @@ function New-RsSubscription {
$EventType = 'TimedSubscription',
[Parameter(Mandatory=$True)]
- [ValidateSet('DocumentLibrary','Email','FileShare')]
[string]
- $Destination,
+ $Schedule,
[Parameter(Mandatory=$True)]
+ [ValidateSet('Email','FileShare')]
[string]
- $Schedule,
+ $DeliveryMethod,
+
+ [Parameter(Mandatory=$True)]
+ [ValidateSet('PDF','MHTML','IMAGE','CSV','XML','EXCELOPENXML','ATOM','PPTX','WORDOPENXML')]
+ [string]
+ $RenderFormat = 'PDF',
[Parameter(ParameterSetName='Email',Mandatory=$True)]
[string]
@@ -133,6 +184,10 @@ function New-RsSubscription {
[string]
$BCC,
+ [Parameter(ParameterSetName='Email')]
+ [string]
+ $ReplyTo,
+
[Parameter(ParameterSetName='Email')]
[switch]
$ExcludeReport,
@@ -141,19 +196,10 @@ function New-RsSubscription {
[string]
$Subject,
- [Parameter(ParameterSetName='FileShare',Mandatory=$True)]
+ [Parameter(ParameterSetName='Email')]
[string]
- $DestinationPath,
+ $Comment,
- [Parameter(ParameterSetName='FileShare',Mandatory=$True)]
- [string]
- $Filename,
-
- [Parameter(Mandatory=$True)]
- [ValidateSet('PDF','MHTML','IMAGE','CSV','XML','EXCELOPENXML','ATOM','PPTX','WORDOPENXML')]
- [string]
- $RenderFormat = 'PDF',
-
[Parameter(ParameterSetName='Email')]
[switch]
$ExcludeLink,
@@ -161,88 +207,112 @@ function New-RsSubscription {
[Parameter(ParameterSetName='Email')]
[ValidateSet('LOW', 'NORMAL', 'HIGH')]
[string]
- $Priority = 'NORMAL'
+ $Priority = 'NORMAL',
+
+ [Alias('DestinationPath')]
+ [Parameter(ParameterSetName='FileShare',Mandatory=$True)]
+ [string]
+ $FileSharePath,
+
+ [Parameter(ParameterSetName='FileShare')]
+ [System.Management.Automation.PSCredential]
+ $FileShareCredentials,
+
+ [Parameter(ParameterSetName='FileShare',Mandatory=$True)]
+ [string]
+ $Filename,
+
+ [Parameter(ParameterSetName='FileShare')]
+ [ValidateSet('None','Overwrite','AutoIncrement')]
+ [string]
+ $FileWriteMode = 'Overwrite'
)
- Begin {
+ Begin
+ {
$Proxy = New-RsWebServiceProxyHelper -BoundParameters $PSBoundParameters
}
- Process {
-
- if ([System.String]::IsNullOrEmpty($Path))
+ Process
+ {
+ if ([System.String]::IsNullOrEmpty($RsItem))
{
- throw 'No report Path was specified! You need to specify -Path variable.'
+ throw 'No report path was specified! You need to specify -RsItem variable.'
}
- if ($Destination -eq 'DocumentLibrary')
- {
- throw 'DocumentLibrary is not yet supported by this cmdlet. Sorry!'
- }
-
- try {
- Write-Verbose "Validating if destination exists..."
-
- if (((Get-RsFolderContent -Proxy $Proxy -RsFolder ((Split-Path $Path -Parent).Replace('\','/')) | Where-Object Path -eq $Path).Count) -eq 0)
+ try
+ {
+ Write-Verbose "Validating if target report exists..."
+ if (((Get-RsFolderContent -Proxy $Proxy -RsFolder ((Split-Path $RsItem -Parent).Replace('\','/')) | Where-Object Path -eq $RsItem).Count) -eq 0)
{
- Write-Warning "Can't find the report $Path. Skipping."
+ Write-Warning "Can't find the report $RsItem. Skipping."
Continue
- }
-
+ }
+
$Namespace = $Proxy.GetType().NameSpace
-
- switch ($Destination)
+
+ switch ($DeliveryMethod)
{
- 'DocumentLibrary' {
- $Params = @{
- # Not yet supported
- }
- }
- 'Email' {
+ 'Email'
+ {
$Params = @{
TO = $To
CC = $CC
BCC = $BCC
+ ReplyTo = $ReplyTo
IncludeReport = (-not $ExcludeReport)
IncludeLink = (-not $ExcludeLink)
Subject = $Subject
+ Comment = $Comment
RenderFormat = $RenderFormat
Priority = $Priority
}
}
- 'FileShare' {
+ 'FileShare'
+ {
$Params = @{
- PATH = $DestinationPath
+ PATH = $FileSharePath
FILENAME = $Filename
RENDER_FORMAT = $RenderFormat
+ WRITEMODE = $FileWriteMode
+ }
+
+ if ($FileShareCredentials -ne $null)
+ {
+ $Params.USERNAME = $FileShareCredentials.UserName
+ $Params.PASSWORD = $FileShareCredentials.GetNetworkCredential().Password
+ $Params.DEFAULTCREDENTIALS = $false
+ }
+ else
+ {
+ $Params.DEFAULTCREDENTIALS = $true
}
}
}
-
- $ParameterValues = @()
+ $ParameterValues = @()
$Params.GetEnumerator() | ForEach-Object {
$ParameterValues = $ParameterValues + (New-Object "$Namespace.ParameterValue" -Property @{ Name = $_.Name; Value = $_.Value })
}
-
- $ExtensionSettings = New-Object "$Namespace.ExtensionSettings" -Property @{ Extension = "Report Server $Destination"; ParameterValues = $ParameterValues }
-
- $MatchData = $Schedule
- $Parameters = $Null
- Write-Verbose "Creating Subscription..."
+ $ExtensionSettings = New-Object "$Namespace.ExtensionSettings" -Property @{ Extension = "Report Server $DeliveryMethod"; ParameterValues = $ParameterValues }
- if ($PSCmdlet.ShouldProcess($Path, "Creating new subscription"))
+ $MatchData = $Schedule
+ $ReportParameters = $Null
+
+ if ($PSCmdlet.ShouldProcess($RsItem, "Creating new subscription"))
{
- $subscriptionId = $Proxy.CreateSubscription($Path,$ExtensionSettings,$Description,$EventType,$MatchData,$Parameters)
+ Write-Verbose "Creating Subscription..."
+ $subscriptionId = $Proxy.CreateSubscription($RsItem, $ExtensionSettings, $Description, $EventType, $MatchData, $ReportParameters)
[pscustomobject]@{
NewSubscriptionId = $subscriptionId
}
- }
-
- Write-Verbose "Subscription created successfully! Generated subscriptionId: $subscriptionId"
- } catch {
+ Write-Verbose "Subscription created successfully! Generated subscriptionId: $subscriptionId"
+ }
+ }
+ catch
+ {
throw (New-Object System.Exception("Exception occurred while creating subscription! $($_.Exception.Message)", $_.Exception))
}
}
diff --git a/ReportingServicesTools/Functions/CatalogItems/Remove-RsCatalogItem.ps1 b/ReportingServicesTools/Functions/CatalogItems/Remove-RsCatalogItem.ps1
index 59bd6348..ea481fb4 100644
--- a/ReportingServicesTools/Functions/CatalogItems/Remove-RsCatalogItem.ps1
+++ b/ReportingServicesTools/Functions/CatalogItems/Remove-RsCatalogItem.ps1
@@ -43,7 +43,7 @@ function Remove-RsCatalogItem
Gets a list of items from the SQL Server Performance Dashboard folder in a GridView from an SSRS instance names SQL2016 and allows the user to select items to be removed, after clicking "OK", only the items selected will be removed.
#>
- [CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = 'Medium')]
+ [CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = 'High')]
param (
[Alias('ItemPath', 'Path', 'RsFolder')]
[Parameter(Mandatory = $True, ValueFromPipeline = $true)]
diff --git a/ReportingServicesTools/Functions/CatalogItems/Remove-RsSubscription.ps1 b/ReportingServicesTools/Functions/CatalogItems/Remove-RsSubscription.ps1
index 234a6879..60918a1f 100644
--- a/ReportingServicesTools/Functions/CatalogItems/Remove-RsSubscription.ps1
+++ b/ReportingServicesTools/Functions/CatalogItems/Remove-RsSubscription.ps1
@@ -5,78 +5,86 @@ function Remove-RsSubscription
{
<#
.SYNOPSIS
- This function removes an subscription from the report.
-
+ This function removes subscription(s) associated to reports.
+
.DESCRIPTION
- This function removes an subscription from the report.
-
+ This function removes subscription(s) associated to reports.
+
.PARAMETER Subscription
- An object returned from Get-RsSubscription that ccontains one or multiple SubscriptionId to remove. It is exclusive with $SubscriptionId parameter.
+ An object returned from Get-RsSubscription that contains one or multiple SubscriptionId to remove. Do NOT specify $SubscriptionId parameter when specifying this parameter.
.PARAMETER SubscriptionId
- The SubscriptionId to remove. It is exclusive with $Subscription parameter.
-
+ The SubscriptionId to remove. Do NOT specify $Subscription parameter when specifying this parameter.
+
.PARAMETER ReportServerUri
Specify the Report Server URL to your SQL Server Reporting Services Instance.
Use the "Connect-RsReportServer" function to set/update a default value.
-
+
.PARAMETER Credential
Specify the credentials to use when connecting to the Report Server.
Use the "Connect-RsReportServer" function to set/update a default value.
-
+
.PARAMETER Proxy
Report server proxy to use.
Use "New-RsWebServiceProxy" to generate a proxy object for reuse.
Useful when repeatedly having to connect to multiple different Report Server.
.EXAMPLE
- Remove-RsSubscription -ReportServerUri http://localhost/ReportServer -SubscriptionId 'b4694569-99a9-4cb3-bd59-7bf710b04a0c'
-
+ Remove-RsSubscription -SubscriptionId 'b4694569-99a9-4cb3-bd59-7bf710b04a0c'
+
Description
-----------
- Removes the subscription with ID 'b4694569-99a9-4cb3-bd59-7bf710b04a0c'
+ Removes the subscription with ID 'b4694569-99a9-4cb3-bd59-7bf710b04a0c' from Report Server located at http://localhost/reportserver
.EXAMPLE
Get-RsSubscription -ReportServerUri http://localhost/ReportServer_SQL2016 -Path '/path/to/my/report' |
Out-GridView -PassThru |
Remove-RsSubscription -ReportServerUri http://localhost/ReportServer_SQL2016
-
+
Description
-----------
- Gets a list of subscriptions from the report in a GridView from an SSRS instance names SQL2016 and allows the user to select items to be removed, after clicking "OK", only the items selected will be removed.
+ Gets all the subscriptions associated to the report located at '/path/to/my/report' found at the Report Server located at http://localhost/ReportServer_SQL2016 and displays them in a gridview. Then it tries to delete all the susbscriptions after prompting user for confirmation.
+
+ .EXAMPLE
+ $rsProxy = New-RsWebServiceyProxy -ReportServerUri http://localhost/ReportServer_SQL2016
+ Get-RsSubscription -Proxy $rsProxy -Path '/path/to/my/report' |
+ Out-GridView -PassThru |
+ Remove-RsSubscription =Proxy $rsProxy
+
+ Description
+ -----------
+ Gets all the subscriptions associated to the report located at '/path/to/my/report' found at the Report Server located at http://localhost/ReportServer_SQL2016 and displays them in a gridview. Then it tries to delete all the susbscriptions after prompting user for confirmation.
#>
- [CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = 'Medium')]
+ [CmdletBinding(SupportsShouldProcess = $True, ConfirmImpact = 'High')]
param (
- [Parameter(ParameterSetName='MutipleSubscriptions', Mandatory = $True, ValueFromPipeline = $true)]
+ [Parameter(ParameterSetName='MutipleSubscriptions', Mandatory=$True, ValueFromPipeline=$True)]
[object[]]
$Subscription,
[Parameter(ParameterSetName='SingleSubscription', Mandatory=$True)]
[string]
$SubscriptionId,
-
+
[string]
$ReportServerUri,
[System.Management.Automation.PSCredential]
$Credential,
-
+
$Proxy
)
-
Begin
{
$Proxy = New-RsWebServiceProxyHelper -BoundParameters $PSBoundParameters
}
-
Process
{
if ([System.String]::IsNullOrEmpty($SubscriptionId))
{
foreach ($item in $Subscription)
{
- if ($PSCmdlet.ShouldProcess($item.SubscriptionId, "Delete the subscription"))
+ if ($PSCmdlet.ShouldProcess($item.SubscriptionId, "Delete the subscription"))
{
try
{
@@ -91,9 +99,9 @@ function Remove-RsSubscription
}
}
}
- else
+ else
{
- if ($PSCmdlet.ShouldProcess($SubscriptionId, "Delete the subscription"))
+ if ($PSCmdlet.ShouldProcess($SubscriptionId, "Delete the subscription"))
{
try
{
diff --git a/ReportingServicesTools/Functions/CatalogItems/Set-RsSubscription.ps1 b/ReportingServicesTools/Functions/CatalogItems/Set-RsSubscription.ps1
index e5fd32d7..54342ba9 100644
--- a/ReportingServicesTools/Functions/CatalogItems/Set-RsSubscription.ps1
+++ b/ReportingServicesTools/Functions/CatalogItems/Set-RsSubscription.ps1
@@ -1,154 +1,142 @@
-# Copyright (c) 2016 Microsoft Corporation. All Rights Reserved.
+# Copyright (c) 2016 Microsoft Corporation. All Rights Reserved.
# Licensed under the MIT License (MIT)
+
function Set-RsSubscription
{
- <#
+ <#
.SYNOPSIS
- This script set a new reporting subscription.
-
+ This script will update subscriptions piped from Get-RsSubscriptions
+
.DESCRIPTION
- This script set a new reporting subscription based on the info of an existing subscription (retrieved using Get-RsSubscription).
- You can choose a specific report or pass a folder. When using a folder, the report must have the same name.
- NOTE: A new subscriptionId will be generated.
-
- .PARAMETER Path
- Specify the path to the destination report. Can't be used with -RsFolder parameter.
-
- .PARAMETER RsFolder
- Specify the folder where the destination reports exists. Can't be used with -Path parameter.
+ This script will take the custom object producted by get-RSSubscription and use the data to update the
+ matchdata xml to either a new startdatetime, enddate, or owner.
- .PARAMETER Subscription
- A object with all subscritpion configurations. The default output of Get-RsSubscription. You must piping it to this command.
-
.PARAMETER ReportServerUri
Specify the Report Server URL to your SQL Server Reporting Services Instance.
Use the "Connect-RsReportServer" function to set/update a default value.
-
+
.PARAMETER Credential
Specify the credentials to use when connecting to the Report Server.
Use the "Connect-RsReportServer" function to set/update a default value.
-
+
.PARAMETER Proxy
Report server proxy to use.
Use "New-RsWebServiceProxy" to generate a proxy object for reuse.
Useful when repeatedly having to connect to multiple different Report Server.
+
+ .PARAMETER StartDateTime
+ StartDateTime to change Start Date and Time of subscription.
- .EXAMPLE
- Get-RsSubscription -ReportServerUri 'http://localhost/ReportServer_sql14' -Path '/path/to/my/oldReport' | Set-RsSubscription -ReportServerUri 'http://remote-machine:8080/reportserver_sql16' -Path '/path/to/newReport'
+ .PARAMETER EndDate
+ Used to change the EndDate of subscription.
+
+ .PARAMETER Owner
+ Used to change the owner of a subscription.
+
+ .EXAMPLE
+ Get-RsSubscription -path '/Finance/ImportantReports' | Set-RsSubscription -EndDate 9/9/2099
+
Description
-----------
- This command will establish a connection to the Report Server located at http://localhost/ReportServer_sql14 using current user's credentials get all subscriptions from report '/path/to/my/oldReport'
- and pipe the results to Set-RsSubscription which will create a new subscription on report '/path/to/newReport' located at Report Server 'http://remote-machine:8080/reportserver_sql16'
+ Update all subscriptions on localhost associated with '/finance/ImportantReports' to have an EndDate of 9/9/2099
-
.EXAMPLE
- Get-RsSubscription -ReportServerUri 'http://localhost/ReportServer_sql14' -Path '/path/to/my/oldReport' | Set-RsSubscription -ReportServerUri 'http://remote-machine:8080/reportserver_sql16' -RsFolder '/New Folder'
-
+ Get-RsSubscription -path '/Finance/ImportantReports' | Set-RsSubscription -StartDateTime "1/9/2017 9am"
+
Description
-----------
- This command will establish a connection to the Report Server located at http://localhost/ReportServer_sql14 using current user's credentials get all subscriptions from report '/path/to/my/oldReport'
- and pipe the results to Set-RsSubscription which will create a new subscription on each report that exists with the same name on the destination folder '/New Folder' located at Report Server 'http://remote-machine:8080/reportserver_sql16'
-
-
+ Update all subscriptions on localhost associated with '/finance/ImportantReports' to have a startdate of 1/9/2017 and time of 9am
+
.EXAMPLE
- $paths = Get-RsCatalogItems -ReportServerUri 'http://localhost/ReportServer_sql14' -RsFolder /Origin | Where-Object TypeName -eq "Report" | Select-Object -ExpandProperty Path
- Get-RsSubscription -ReportServerUri 'http://localhost/ReportServer_sql14' -Path $paths | Set-RsSubscription -ReportServerUri 'http://remote-machine:8080/reportserver_sql16' -RsFolder '/New Folder'
+ Get-RsSubscription -path '/Finance/ImportantReports' | Set-RsSubscription -Owner "Warren"
Description
-----------
- This command will establish a connection to the Report Server located at http://localhost/ReportServer_sql14 using current user's credentials get all the paths from all reports at '/Origin' folder.
- Then it uses the $paths variable to get all existing subscriptions and pipe the results to Set-RsSubscription which will create a new subscription on each report that exists with the same name on the destination folder '/New Folder' located at Report Server 'http://remote-machine:8080/reportserver_sql16'
+ Update all subscriptions on localhost associated with '/finance/ImportantReports' to have an owner of "Warren".
+ The user being updated needs to have the correct permissions in order to successfully update the owner.
+
#>
- [cmdletbinding(SupportsShouldProcess = $true, ConfirmImpact = 'Medium')]
- param
- (
- [string]
- $ReportServerUri,
-
- [System.Management.Automation.PSCredential]
- $Credential,
+ [CmdletBinding()]
+ param (
+ [string]
+ $ReportServerUri,
+
+ [System.Management.Automation.PSCredential]
+ $Credential,
+
+ $Proxy,
+
+ [parameter(Mandatory = $false)]
+ [DateTime]$StartDateTime,
+
+ [parameter(Mandatory = $false)]
+ [DateTime]$EndDate,
+
+ [parameter(Mandatory = $False)]
+ [string]$Owner,
+
+ [Parameter(Mandatory=$true,ValueFromPipeLine)]
+ [PSCustomObject[]]$SubProperties
- $Proxy,
-
- [Alias('ReportPath','ItemPath')]
- [Parameter(ParameterSetName='Report', Mandatory=$True)]
- [string]
- $Path,
-
- [Alias('Folder')]
- [Parameter(ParameterSetName='Folder', Mandatory=$True)]
- [string]
- $RsFolder,
-
- [Parameter(Mandatory = $True, ValueFromPipeline=$true)]
- [object[]]
- $Subscription
- )
- Begin
+ )
+
+ Begin
+ {
+ $Proxy = New-RsWebServiceProxyHelper -BoundParameters $PSBoundParameters
+
+ }
+ Process
+ {
+ Write-Verbose "Updating Subscriptions..."
+try
+ {
+ [xml]$XMLMatch = $SubProperties.MatchData
+
+ if ($owner){
+ $proxy.ChangeSubscriptionOwner($SubProperties.subscriptionID,$owner)
+ }
+
+
+ if ($StartDateTime)
{
- $Proxy = New-RsWebServiceProxyHelper -BoundParameters $PSBoundParameters
- $Namespace = $Proxy.GetType().NameSpace
+ $XMLMatch.ScheduleDefinition.StartDateTime.InnerText = $StartDateTime
}
- Process
+ if ($EndDate)
{
- #region Input Validation
- if ([System.String]::IsNullOrEmpty($Path) -and [System.String]::IsNullOrEmpty($RsFolder))
- {
- throw 'No Folder or report Path was specified! You need to specify -RsFolder or -Path variable.'
- }
-
- #endregion Input Validation
-
- try
- {
- foreach ($sub in $Subscription)
- {
- if ($RsFolder)
- {
- $Path = "$RsFolder/$($sub.Report)"
- }
- else
- {
- $RsFolder = (Split-Path $Path -Parent).Replace("\", "/")
- }
-
- Write-Verbose "Validating if destination exists..."
-
- if (((Get-RsFolderContent -Proxy $Proxy -RsFolder $RsFolder | Where-Object Path -eq $Path).Count) -eq 0)
- {
- Write-Warning "Can't find the report $Path. Skipping."
- Continue
- }
-
- if ($PSCmdlet.ShouldProcess($Path, "Creating new subscription"))
- {
- Write-Verbose "Creating Subscription..."
-
- if ($subscription.IsDataDriven)
- {
- $subscriptionId = $Proxy.CreateDataDrivenSubscription($Path, $sub.DeliverySettings, $sub.DataRetrievalPlan, $sub.Description, $sub.EventType, $sub.MatchData, $sub.Values)
- }
- else
- {
- $subscriptionId = $Proxy.CreateSubscription($Path, $sub.DeliverySettings, $sub.Description, $sub.EventType, $sub.MatchData, $sub.Values)
- }
- }
-
- [pscustomobject]@{
- NewSubscriptionId = $subscriptionId
- DestinationReport = $Path
- OriginalReport = $sub.Path
- }
- Write-Verbose "Subscription created successfully! Generated subscriptionId: $subscriptionId"
- }
- }
- catch
- {
- throw (New-Object System.Exception("Exception occurred while creating subscription! $($_.Exception.Message)", $_.Exception))
- }
+ #check to see if end date exists as a node
+ $EndExists = $XMLMatch.SelectNodes("//*") | Select-Object name | Where-Object name -eq "EndDate"
+ #if no enddate create child node
+ if ($EndExists -eq $null)
+ {
+ $child = $XMLMatch.CreateElement("EndDate")
+ $child.InnerText = $EndDate
+
+ $XMLMatch.ScheduleDefinition.AppendChild($child)
+
+ }
+ else
+ {
+ #if enddate node exists update
+ $XMLMatch.ScheduleDefinition.EndDate.InnerText = $EndDate
+ }
+
+ }
+
+ if ($StartDateTime -ne $null -or $EndDate -ne $null)
+ {
+ $null = $Proxy.SetSubscriptionProperties($SubProperties.subscriptionID, $SubProperties.DeliverySettings, $SubProperties.Description, $SubProperties.EventType, $XMLMatch.OuterXml, $SubProperties.Values)
+ Write-Verbose "subscription $($SubProperties.subscriptionId) for $($SubProperties.report) report successfully updated!"
}
+ }
+ Catch
+ {
+ throw (New-Object System.Exception("Exception while updating subscription(s)! $($_.Exception.Message)", $_.Exception))
+ }
+
+ }
}
+
diff --git a/ReportingServicesTools/Functions/CatalogItems/Update-RsSubscription.ps1 b/ReportingServicesTools/Functions/CatalogItems/Update-RsSubscription.ps1
deleted file mode 100644
index 43aa2192..00000000
--- a/ReportingServicesTools/Functions/CatalogItems/Update-RsSubscription.ps1
+++ /dev/null
@@ -1,142 +0,0 @@
-# Copyright (c) 2016 Microsoft Corporation. All Rights Reserved.
-# Licensed under the MIT License (MIT)
-
-
-function Update-RsSubscription
-{
- <#
- .SYNOPSIS
- This script will update subscriptions piped from Get-RsSubscriptions
-
- .DESCRIPTION
- This script will take the custom object producted by get-RSSubscription and use the data to update the
- matchdata xml to either a new startdatetime, enddate, or owner.
-
- .PARAMETER ReportServerUri
- Specify the Report Server URL to your SQL Server Reporting Services Instance.
- Use the "Connect-RsReportServer" function to set/update a default value.
-
- .PARAMETER Credential
- Specify the password to use when connecting to your SQL Server Reporting Services Instance.
- Use the "Connect-RsReportServer" function to set/update a default value.
-
- .PARAMETER Proxy
- Report server proxy to use.
- Use "New-RsWebServiceProxy" to generate a proxy object for reuse.
- Useful when repeatedly having to connect to multiple different Report Server.
-
- .PARAMETER StartDateTime
- StartDateTime to change Start Date and Time of subscription.
-
- .PARAMETER EndDate
- Used to change the EndDate of subscription.
-
- .PARAMETER Owner
- Used to change the owner of a subscription.
-
-
- .EXAMPLE
- Get-RsSubscription -path '/Finance/ImportantReports' | Update-RsSubscription -EndDate 9/9/2099
-
- Description
- -----------
- Update all subscriptions on localhost associated with '/finance/ImportantReports' to have an EndDate of 9/9/2099
-
- .EXAMPLE
- Get-RsSubscription -path '/Finance/ImportantReports' | Update-RsSubscription -StartDateTime "1/9/2017 9am"
-
- Description
- -----------
- Update all subscriptions on localhost associated with '/finance/ImportantReports' to have a startdate of 1/9/2017 and time of 9am
-
- .EXAMPLE
- Get-RsSubscription -path '/Finance/ImportantReports' | Update-RsSubscription -Owner "Warren"
-
- Description
- -----------
- Update all subscriptions on localhost associated with '/finance/ImportantReports' to have an owner of "Warren".
- The user being updated needs to have the correct permissions in order to successfully update the owner.
-
- #>
-
- [CmdletBinding()]
- param (
- [string]
- $ReportServerUri,
-
- [System.Management.Automation.PSCredential]
- $Credential,
-
- $Proxy,
-
- [parameter(Mandatory = $false)]
- [DateTime]$StartDateTime,
-
- [parameter(Mandatory = $false)]
- [DateTime]$EndDate,
-
- [parameter(Mandatory = $False)]
- [string]$Owner,
-
- [Parameter(Mandatory=$true,ValueFromPipeLine)]
- [PSCustomObject[]]$SubProperties
-
- )
-
- Begin
- {
- $Proxy = New-RsWebServiceProxyHelper -BoundParameters $PSBoundParameters
-
- }
- Process
- {
- Write-Verbose "Updating Subscriptions..."
-try
- {
- [xml]$XMLMatch = $SubProperties.MatchData
-
- if ($owner){
- $proxy.ChangeSubscriptionOwner($SubProperties.subscriptionID,$owner)
- }
-
-
- if ($StartDateTime)
- {
- $XMLMatch.ScheduleDefinition.StartDateTime.InnerText = $StartDateTime
- }
-
- if ($EndDate)
- {
- #check to see if end date exists as a node
- $EndExists = $XMLMatch.SelectNodes("//*") | Select-Object name | Where-Object name -eq "EndDate"
- #if no enddate create child node
- if ($EndExists -eq $null)
- {
- $child = $XMLMatch.CreateElement("EndDate")
- $child.InnerText = $EndDate
-
- $XMLMatch.ScheduleDefinition.AppendChild($child)
-
- }
- else
- {
- #if enddate node exists update
- $XMLMatch.ScheduleDefinition.EndDate.InnerText = $EndDate
- }
-
- }
-
- if ($StartDateTime -ne $null -or $EndDate -ne $null)
- {
- $null = $Proxy.SetSubscriptionProperties($SubProperties.subscriptionID, $SubProperties.DeliverySettings, $SubProperties.Description, $SubProperties.EventType, $XMLMatch.OuterXml, $SubProperties.Values)
- Write-Verbose "subscription $($SubProperties.subscriptionId) for $($SubProperties.report) report successfully updated!"
- }
- }
- Catch
- {
- throw (New-Object System.Exception("Exception while updating subscription(s)! $($_.Exception.Message)", $_.Exception))
- }
-
- }
-}
-
diff --git a/ReportingServicesTools/ReportingServicesTools.psd1 b/ReportingServicesTools/ReportingServicesTools.psd1
index c6816c5d..90f74339 100644
--- a/ReportingServicesTools/ReportingServicesTools.psd1
+++ b/ReportingServicesTools/ReportingServicesTools.psd1
@@ -64,6 +64,7 @@
FunctionsToExport = @(
'Backup-RsEncryptionKey',
'Connect-RsReportServer',
+ 'Copy-RsSubscription',
'Export-RsSubscriptionXml',
'Get-RsCatalogItemRole',
'Get-RsDataSource',
@@ -110,7 +111,6 @@
'Set-RsSubscription',
'Set-RsUrlReservation',
'Set-PbiRsUrlReservation',
- 'Update-RsSubscription',
'Write-RsCatalogItem',
'Write-RsFolderContent',
'Write-RsRestCatalogItem',
diff --git a/Tests/CatalogItems/Copy-RsSubscription.Tests.ps1 b/Tests/CatalogItems/Copy-RsSubscription.Tests.ps1
new file mode 100644
index 00000000..400f4ce0
--- /dev/null
+++ b/Tests/CatalogItems/Copy-RsSubscription.Tests.ps1
@@ -0,0 +1,341 @@
+# Copyright (c) 2016 Microsoft Corporation. All Rights Reserved.
+# Licensed under the MIT License (MIT)
+
+$reportServerUri = if ($env:PesterServerUrl -eq $null) { 'http://localhost/reportserver' } else { $env:PesterServerUrl }
+
+#Not in use right now - need email configuration on the report server
+Function New-InMemoryEmailSubscription
+{
+
+ [xml]$matchData = '2017-07-14T08:00:00.000+01:001truetruetruetruetrue'
+
+ $proxy = New-RsWebServiceProxy -ReportServerUri $reportServerUri
+ $namespace = $proxy.GetType().NameSpace
+
+ $ExtensionSettingsDataType = "$namespace.ExtensionSettings"
+ $ParameterValueOrFieldReference = "$namespace.ParameterValueOrFieldReference[]"
+ $ParameterValueDataType = "$namespace.ParameterValue"
+
+ #Set ExtensionSettings
+ $ExtensionSettings = New-Object $ExtensionSettingsDataType
+
+ $ExtensionSettings.Extension = "Report Server Email"
+
+ #Set ParameterValues
+ $ParameterValues = New-Object $ParameterValueOrFieldReference -ArgumentList 8
+
+ $to = New-Object $ParameterValueDataType
+ $to.Name = "TO";
+ $to.Value = "mail@rstools.com";
+ $ParameterValues[0] = $to;
+
+ $replyTo = New-Object $ParameterValueDataType
+ $replyTo.Name = "ReplyTo";
+ $replyTo.Value ="dank@rstools.com";
+ $ParameterValues[1] = $replyTo;
+
+ $includeReport = New-Object $ParameterValueDataType
+ $includeReport.Name = "IncludeReport";
+ $includeReport.Value = "False";
+ $ParameterValues[2] = $includeReport;
+
+ $renderFormat = New-Object $ParameterValueDataType
+ $renderFormat.Name = "RenderFormat";
+ $renderFormat.Value = "MHTML";
+ $ParameterValues[3] = $renderFormat;
+
+ $priority = New-Object $ParameterValueDataType
+ $priority.Name = "Priority";
+ $priority.Value = "NORMAL";
+ $ParameterValues[4] = $priority;
+
+ $subject = New-Object $ParameterValueDataType
+ $subject.Name = "Subject";
+ $subject.Value = "Your sales report";
+ $ParameterValues[5] = $subject;
+
+ $comment = New-Object $ParameterValueDataType
+ $comment.Name = "Comment";
+ $comment.Value = "Here is the link to your report.";
+ $ParameterValues[6] = $comment;
+
+ $includeLink = New-Object $ParameterValueDataType
+ $includeLink.Name = "IncludeLink";
+ $includeLink.Value = "True";
+ $ParameterValues[7] = $includeLink;
+
+ $ExtensionSettings.ParameterValues = $ParameterValues
+
+ $subscription = [pscustomobject]@{
+ DeliverySettings = $ExtensionSettings
+ Description = "Send email to mail@rstools.com"
+ EventType = "TimedSubscription"
+ IsDataDriven = $false
+ MatchData = $matchData.OuterXml
+ Values = $null
+ }
+
+ return $subscription
+}
+
+Function New-InMemoryFileShareSubscription
+{
+ [xml]$matchData = '2017-07-14T08:00:00.000+01:001truetruetruetruetrue'
+
+ $proxy = New-RsWebServiceProxy -ReportServerUri $reportServerUri
+ $namespace = $proxy.GetType().NameSpace
+
+ $ExtensionSettingsDataType = "$namespace.ExtensionSettings"
+ $ParameterValueOrFieldReference = "$namespace.ParameterValueOrFieldReference[]"
+ $ParameterValueDataType = "$namespace.ParameterValue"
+
+ #Set ExtensionSettings
+ $ExtensionSettings = New-Object $ExtensionSettingsDataType
+ $ExtensionSettings.Extension = "Report Server FileShare"
+
+ #Set ParameterValues
+ $ParameterValues = New-Object $ParameterValueOrFieldReference -ArgumentList 7
+
+ $to = New-Object $ParameterValueDataType
+ $to.Name = "PATH";
+ $to.Value = "\\unc\path";
+ $ParameterValues[0] = $to;
+
+ $replyTo = New-Object $ParameterValueDataType
+ $replyTo.Name = "FILENAME";
+ $replyTo.Value ="Report";
+ $ParameterValues[1] = $replyTo;
+
+ $includeReport = New-Object $ParameterValueDataType
+ $includeReport.Name = "FILEEXTN";
+ $includeReport.Value = "True";
+ $ParameterValues[2] = $includeReport;
+
+ $renderFormat = New-Object $ParameterValueDataType
+ $renderFormat.Name = "USERNAME";
+ $renderFormat.Value = "user";
+ $ParameterValues[3] = $renderFormat;
+
+ $priority = New-Object $ParameterValueDataType
+ $priority.Name = "RENDER_FORMAT";
+ $priority.Value = "PDF";
+ $ParameterValues[4] = $priority;
+
+ $subject = New-Object $ParameterValueDataType
+ $subject.Name = "WRITEMODE";
+ $subject.Value = "Overwrite";
+ $ParameterValues[5] = $subject;
+
+ $comment = New-Object $ParameterValueDataType
+ $comment.Name = "DEFAULTCREDENTIALS";
+ $comment.Value = "False";
+ $ParameterValues[6] = $comment;
+
+ $ExtensionSettings.ParameterValues = $ParameterValues
+
+ $subscription = [pscustomobject]@{
+ DeliverySettings = $ExtensionSettings
+ Description = "Shared on \\unc\path"
+ EventType = "TimedSubscription"
+ IsDataDriven = $false
+ MatchData = $matchData.OuterXml
+ Values = $null
+ }
+
+ return $subscription
+}
+
+Function Set-FolderReportDataSource {
+ param (
+ [string]
+ $NewFolderPath
+ )
+
+ $tempProxy = New-RsWebServiceProxy -ReportServerUri $reportServerUri
+
+ # uploading emptyReport.rdl
+ $localResourcesPath = (Get-Item -Path ".\").FullName + '\Tests\CatalogItems\testResources\emptyReport.rdl'
+ $null = Write-RsCatalogItem -Path $localResourcesPath -RsFolder $NewFolderPath -Proxy $tempProxy
+ $report = (Get-RsFolderContent -RsFolder $NewFolderPath -Proxy $tempProxy)| Where-Object TypeName -eq 'Report'
+
+ # uploading UnDataset.rsd
+ $localResourcesPath = (Get-Item -Path ".\").FullName + '\Tests\CatalogItems\testResources\UnDataset.rsd'
+ $null = Write-RsCatalogItem -Path $localResourcesPath -RsFolder $NewFolderPath -Proxy $tempProxy
+ $dataSet = (Get-RsFolderContent -RsFolder $NewFolderPath -Proxy $tempProxy) | Where-Object TypeName -eq 'DataSet'
+ $DataSetPath = $NewFolderPath + '/UnDataSet'
+
+ # creating a shared data source with Dummy credentials
+ $newRSDSName = "DataSource"
+ $newRSDSExtension = "SQL"
+ $newRSDSConnectionString = "Initial Catalog=DB; Data Source=Instance"
+ $newRSDSCredentialRetrieval = "Store"
+ $Pass = ConvertTo-SecureString -String "123" -AsPlainText -Force
+ $newRSDSCredential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList "sql", $Pass
+ $null = New-RsDataSource -RsFolder $NewFolderPath -Name $newRSDSName -Extension $newRSDSExtension -ConnectionString $newRSDSConnectionString -CredentialRetrieval $newRSDSCredentialRetrieval -DatasourceCredentials $newRSDSCredential -Proxy $tempProxy
+
+ $DataSourcePath = "$NewFolderPath/$newRSDSName"
+
+ # retrieving embedded dataset and datasources
+ $RsDataSet = Get-RsItemReference -Path $report.Path -Proxy $tempProxy | Where-Object ReferenceType -eq 'DataSet'
+ $RsDataSource = Get-RsItemReference -Path $report.Path -Proxy $tempProxy | Where-Object ReferenceType -eq 'DataSource'
+ $RsDataSetSource = Get-RsItemReference -Path $DataSetPath -Proxy $tempProxy | Where-Object ReferenceType -eq 'DataSource'
+
+ # Set data source and data set for all objects
+ $null = Set-RsDataSourceReference -Path $DataSetPath -DataSourceName $RsDataSetSource.Name -DataSourcePath $DataSourcePath -Proxy $tempProxy
+ $null = Set-RsDataSourceReference -Path $report.Path -DataSourceName $RsDataSource.Name -DataSourcePath $DataSourcePath -Proxy $tempProxy
+ $null = Set-RsDataSetReference -Path $report.Path -DataSetName $RsDataSet.Name -DataSetPath $dataSet.Path -Proxy $tempProxy
+
+ return $report
+}
+
+Describe "Copy-RsSubscription" {
+ $folderPath = ''
+ $newReport = $null
+ $subscription = $null
+
+ BeforeEach {
+ $folderName = 'SutGetRsItemReference_MinParameters' + [guid]::NewGuid()
+ $null = New-RsFolder -Path / -FolderName $folderName -ReportServerUri $reportServerUri
+ $folderPath = '/' + $folderName
+
+ # upload test reports and initialize data sources/data sets
+ $newReport = Set-FolderReportDataSource($folderPath)
+
+ # create a test subscription
+ $subscription = New-InMemoryFileShareSubscription
+ }
+
+ AfterEach {
+ Remove-RsCatalogItem -RsFolder $folderPath -ReportServerUri $reportServerUri -Confirm:$false -ErrorAction Continue
+ }
+
+ Context "Copy-RsSubscription with Proxy parameter"{
+ It "Should set a subscription" {
+ $proxy = New-RsWebServiceProxy -ReportServerUri $reportServerUri
+ Copy-RsSubscription -Subscription $subscription -Path $newReport.Path -Proxy $proxy
+
+ $reportSubscriptions = Get-RsSubscription -Path $newReport.Path -ReportServerUri $reportServerUri
+ @($reportSubscriptions).Count | Should Be 1
+ $reportSubscriptions.Report | Should Be "emptyReport"
+ $reportSubscriptions.EventType | Should Be "TimedSubscription"
+ $reportSubscriptions.IsDataDriven | Should Be $false
+ }
+ }
+
+ Context "Copy-RsSubscription with ReportServerUri Parameter"{
+ It "Should set a subscription" {
+ Copy-RsSubscription -Subscription $subscription -Path $newReport.Path -ReportServerUri $reportServerUri
+
+ $reportSubscriptions = Get-RsSubscription -Path $newReport.Path -ReportServerUri $reportServerUri
+ @($reportSubscriptions).Count | Should Be 1
+ $reportSubscriptions.Report | Should Be "emptyReport"
+ $reportSubscriptions.EventType | Should Be "TimedSubscription"
+ $reportSubscriptions.IsDataDriven | Should Be $false
+ }
+ }
+
+ Context "Copy-RsSubscription with ReportServerUri and Proxy Parameter"{
+ It "Should set a subscription" {
+ $proxy = New-RsWebServiceProxy -ReportServerUri $ReportServerUri
+ Copy-RsSubscription -ReportServerUri $ReportServerUri -Subscription $subscription -Path $newReport.Path -Proxy $proxy
+
+ $reportSubscriptions = Get-RsSubscription -Path $newReport.Path -ReportServerUri $reportServerUri
+ @($reportSubscriptions).Count | Should Be 1
+ $reportSubscriptions.Report | Should Be "emptyReport"
+ $reportSubscriptions.EventType | Should Be "TimedSubscription"
+ $reportSubscriptions.IsDataDriven | Should Be $false
+ }
+ }
+}
+
+Describe "Copy-RsSubscription from pipeline" {
+ $folderPath = ''
+ $newReport = $null
+ $subscription = $null
+
+ BeforeEach {
+ $folderName = 'SutGetRsItemReference_MinParameters' + [guid]::NewGuid()
+ $null = New-RsFolder -Path / -FolderName $folderName -ReportServerUri $reportServerUri
+ $folderPath = '/' + $folderName
+
+ # upload test reports and initialize data sources/data sets
+ $newReport = Set-FolderReportDataSource($folderPath)
+
+ # create a test subscription
+ $subscription = New-InMemoryFileShareSubscription
+ }
+
+ AfterEach {
+ Remove-RsCatalogItem -RsFolder $folderPath -ReportServerUri $reportServerUri -Confirm:$false -ErrorAction Continue
+ }
+
+ Context "Copy-RsSubscription from pipeline with Proxy parameter"{
+ It "Should set a subscription" {
+ $proxy = New-RsWebServiceProxy -ReportServerUri $reportServerUri
+
+ # Copy first subscription
+ Copy-RsSubscription -Subscription $subscription -Path $newReport.Path -Proxy $proxy
+
+ # Duplicate subscription
+ Get-RsSubscription -Path $newReport.Path -Proxy $proxy | Copy-RsSubscription -Path $newReport.Path -Proxy $proxy
+
+ # Get both subscription
+ $reportSubscriptions = Get-RsSubscription -Path $newReport.Path -ReportServerUri $reportServerUri
+ @($reportSubscriptions).Count | Should Be 2
+ ($reportSubscriptions | Select-Object SubscriptionId -Unique).Count | Should Be 2
+ }
+ }
+
+ Context "Copy-RsSubscription from pipeline with ReportServerUri Parameter"{
+ It "Should copy a subscription" {
+ # Copy first subscription
+ Copy-RsSubscription -Subscription $subscription -Path $newReport.Path -ReportServerUri $reportServerUri
+
+ # Duplicate subscription
+ Get-RsSubscription -Path $newReport.Path -ReportServerUri $reportServerUri | Copy-RsSubscription -Path $newReport.Path -ReportServerUri $reportServerUri
+
+ # Get both subscription
+ $reportSubscriptions = Get-RsSubscription -Path $newReport.Path -ReportServerUri $reportServerUri
+ @($reportSubscriptions).Count | Should Be 2
+ ($reportSubscriptions | Select-Object SubscriptionId -Unique).Count | Should Be 2
+ }
+ }
+
+ Context "Copy-RsSubscription from pipeline with ReportServerUri and Proxy Parameter"{
+ It "Should copy a subscription" {
+ $proxy = New-RsWebServiceProxy -ReportServerUri $reportServerUri
+
+ # Copy first subscription
+ Copy-RsSubscription -Subscription $subscription -Path $newReport.Path -ReportServerUri $reportServerUri -Proxy $proxy
+
+ # Duplicate subscription
+ Get-RsSubscription -Path $newReport.Path -ReportServerUri $reportServerUri -Proxy $proxy | Copy-RsSubscription -Path $newReport.Path -ReportServerUri $reportServerUri -Proxy $proxy
+
+ # Get both subscription
+ $reportSubscriptions = Get-RsSubscription -Path $newReport.Path -ReportServerUri $reportServerUri
+ @($reportSubscriptions).Count | Should Be 2
+ ($reportSubscriptions | Select-Object SubscriptionId -Unique).Count | Should Be 2
+ }
+ }
+
+ Context "Copy-RsSubscription from pipeline with input from disk"{
+ It "Should copy a subscription" {
+ $TestPath = 'TestDrive:\Subscription.xml'
+ $subscription | Export-RsSubscriptionXml $TestPath
+ $subscriptionFromDisk = Import-RsSubscriptionXml $TestPath -ReportServerUri $reportServerUri
+
+ $proxy = New-RsWebServiceProxy -ReportServerUri $reportServerUri
+
+ # Copy first subscription
+ Copy-RsSubscription -Subscription $subscriptionFromDisk -Path $newReport.Path -ReportServerUri $reportServerUri -Proxy $proxy
+
+ # Duplicate subscription
+ Get-RsSubscription -Path $newReport.Path -ReportServerUri $reportServerUri -Proxy $proxy | Copy-RsSubscription -Path $newReport.Path -ReportServerUri $reportServerUri -Proxy $proxy
+
+ # Get both subscription
+ $reportSubscriptions = Get-RsSubscription -Path $newReport.Path -ReportServerUri $reportServerUri
+ @($reportSubscriptions).Count | Should Be 2
+ ($reportSubscriptions | Select-Object SubscriptionId -Unique).Count | Should Be 2
+ }
+ }
+}
diff --git a/Tests/CatalogItems/Get-RsDataSource.Tests.ps1 b/Tests/CatalogItems/Get-RsDataSource.Tests.ps1
index 1e6148ae..189fb6f7 100644
--- a/Tests/CatalogItems/Get-RsDataSource.Tests.ps1
+++ b/Tests/CatalogItems/Get-RsDataSource.Tests.ps1
@@ -22,7 +22,7 @@ Describe "Get-RsDataSource" {
$dataSource.Count | Should Be 1
}
# Removing folders used for testing
- Remove-RsCatalogItem -RsFolder $dataSourcePath
+ Remove-RsCatalogItem -RsFolder $dataSourcePath -Confirm:$false
}
Context "Get RsDataSource with Proxy parameter"{
@@ -38,7 +38,7 @@ Describe "Get-RsDataSource" {
$dataSource.Count | Should Be 1
}
# Removing folders used for testing
- Remove-RsCatalogItem -RsFolder $dataSourcePath
+ Remove-RsCatalogItem -RsFolder $dataSourcePath -Confirm:$false
}
Context "Get RsDataSource with Proxy y ReportServerUri parameters"{
@@ -56,6 +56,6 @@ Describe "Get-RsDataSource" {
$dataSource.Count | Should Be 1
}
# Removing folders used for testing
- Remove-RsCatalogItem -RsFolder $dataSourcePath
+ Remove-RsCatalogItem -RsFolder $dataSourcePath -Confirm:$false
}
}
\ No newline at end of file
diff --git a/Tests/CatalogItems/Get-RsFolderContentTests.ps1 b/Tests/CatalogItems/Get-RsFolderContentTests.ps1
index d63931b1..2d4d8dda 100644
--- a/Tests/CatalogItems/Get-RsFolderContentTests.ps1
+++ b/Tests/CatalogItems/Get-RsFolderContentTests.ps1
@@ -16,7 +16,7 @@ Describe "Get-RsFolderContent" {
$folderCount | Should Be 1
}
# Removing folders used for testing
- Remove-RsCatalogItem -ReportServerUri 'http://localhost/reportserver' -RsFolder $folderPath
+ Remove-RsCatalogItem -ReportServerUri 'http://localhost/reportserver' -RsFolder $folderPath -Confirm:$false
}
Context "Get folder with proxy parameter"{
@@ -33,7 +33,7 @@ Describe "Get-RsFolderContent" {
$folderCount | Should Be 1
}
# Removing folders used for testing
- Remove-RsCatalogItem -ReportServerUri 'http://localhost/reportserver' -RsFolder $folderPath
+ Remove-RsCatalogItem -ReportServerUri 'http://localhost/reportserver' -RsFolder $folderPath -Confirm:$false
}
Context "Get folder with Proxy and ReportServerUri parameter"{
@@ -51,7 +51,7 @@ Describe "Get-RsFolderContent" {
$folderCount | Should Be 1
}
# Removing folders used for testing
- Remove-RsCatalogItem -ReportServerUri 'http://localhost/reportserver' -RsFolder $folderPath
+ Remove-RsCatalogItem -ReportServerUri 'http://localhost/reportserver' -RsFolder $folderPath -Confirm:$false
}
Context "Get folder inside 4 folders"{
@@ -80,6 +80,6 @@ Describe "Get-RsFolderContent" {
$folderList.Count | Should be 4
}
# Removing folders used for testing
- Remove-RsCatalogItem -ReportServerUri 'http://localhost/reportserver' -RsFolder $rootFolderPath
+ Remove-RsCatalogItem -ReportServerUri 'http://localhost/reportserver' -RsFolder $rootFolderPath -Confirm:$false
}
}
\ No newline at end of file
diff --git a/Tests/CatalogItems/Get-RsItemDataSource.Tests.ps1 b/Tests/CatalogItems/Get-RsItemDataSource.Tests.ps1
index f262ceb0..03265989 100644
--- a/Tests/CatalogItems/Get-RsItemDataSource.Tests.ps1
+++ b/Tests/CatalogItems/Get-RsItemDataSource.Tests.ps1
@@ -26,9 +26,9 @@ Describe "Get-RsItemDataSource" {
}
AfterEach {
- Remove-RsCatalogItem -ReportServerUri $reportServerUri -RsItem $datasourcesReportPath
- Remove-RsCatalogItem -ReportServerUri $reportServerUri -RsItem $noDatasourcesReportPath
- Remove-RsCatalogItem -ReportServerUri $reportServerUri -RsItem $rsFolderPath
+ Remove-RsCatalogItem -ReportServerUri $reportServerUri -RsItem $datasourcesReportPath -Confirm:$false
+ Remove-RsCatalogItem -ReportServerUri $reportServerUri -RsItem $noDatasourcesReportPath -Confirm:$false
+ Remove-RsCatalogItem -ReportServerUri $reportServerUri -RsItem $rsFolderPath -Confirm:$false
}
Context "Fetches data sources with explicit ReportServerUri parameter"{
diff --git a/Tests/CatalogItems/Get-RsItemReference.Tests.ps1 b/Tests/CatalogItems/Get-RsItemReference.Tests.ps1
index 1425b0a5..25d4c958 100644
--- a/Tests/CatalogItems/Get-RsItemReference.Tests.ps1
+++ b/Tests/CatalogItems/Get-RsItemReference.Tests.ps1
@@ -21,7 +21,7 @@ Describe "Get-RsItemReference" {
$dataSourceReference = $reportReferences | Where-Object ReferenceType -eq 'DataSource'
$dataSourceReference.Name | Should Be 'reportReferenceDataSource'
}
- Remove-RsCatalogItem -RsFolder $folderPath
+ Remove-RsCatalogItem -RsFolder $folderPath -Confirm:$false
}
Context "Get-RsItemReference with Proxy parameter"{
@@ -39,7 +39,7 @@ Describe "Get-RsItemReference" {
$dataSourceReference = $reportReferences | Where-Object ReferenceType -eq 'DataSource'
$dataSourceReference.Name | Should Be 'reportReferenceDataSource'
}
- Remove-RsCatalogItem -RsFolder $folderPath
+ Remove-RsCatalogItem -RsFolder $folderPath -Confirm:$false
}
Context "Get-RsItemReference with ReportServerUri Parameter"{
@@ -57,7 +57,7 @@ Describe "Get-RsItemReference" {
$dataSourceReference = $reportReferences | Where-Object ReferenceType -eq 'DataSource'
$dataSourceReference.Name | Should Be 'reportReferenceDataSource'
}
- Remove-RsCatalogItem -RsFolder $folderPath
+ Remove-RsCatalogItem -RsFolder $folderPath -Confirm:$false
}
Context "Get-RsItemReference with ReportServerUri and Proxy Parameter"{
@@ -76,6 +76,6 @@ Describe "Get-RsItemReference" {
$dataSourceReference = $reportReferences | Where-Object ReferenceType -eq 'DataSource'
$dataSourceReference.Name | Should Be 'reportReferenceDataSource'
}
- Remove-RsCatalogItem -RsFolder $folderPath
+ Remove-RsCatalogItem -RsFolder $folderPath -Confirm:$false
}
}
\ No newline at end of file
diff --git a/Tests/CatalogItems/Get-RsSubscription.Tests.ps1 b/Tests/CatalogItems/Get-RsSubscription.Tests.ps1
index 13e85a78..382ab6a7 100644
--- a/Tests/CatalogItems/Get-RsSubscription.Tests.ps1
+++ b/Tests/CatalogItems/Get-RsSubscription.Tests.ps1
@@ -1,147 +1,7 @@
# Copyright (c) 2016 Microsoft Corporation. All Rights Reserved.
# Licensed under the MIT License (MIT)
-#Not in use right now - need email configuration on the report server
-Function Get-NewEmailSubscription
-{
-
- [xml]$matchData = '2017-07-14T08:00:00.000+01:001truetruetruetruetrue'
-
- $proxy = New-RsWebServiceProxy
- $namespace = $proxy.GetType().NameSpace
-
- $ExtensionSettingsDataType = "$namespace.ExtensionSettings"
- $ParameterValueOrFieldReference = "$namespace.ParameterValueOrFieldReference[]"
- $ParameterValueDataType = "$namespace.ParameterValue"
-
- #Set ExtensionSettings
- $ExtensionSettings = New-Object $ExtensionSettingsDataType
-
- $ExtensionSettings.Extension = "Report Server Email"
-
- #Set ParameterValues
- $ParameterValues = New-Object $ParameterValueOrFieldReference -ArgumentList 8
-
- $to = New-Object $ParameterValueDataType
- $to.Name = "TO";
- $to.Value = "mail@rstools.com";
- $ParameterValues[0] = $to;
-
- $replyTo = New-Object $ParameterValueDataType
- $replyTo.Name = "ReplyTo";
- $replyTo.Value ="dank@rstools.com";
- $ParameterValues[1] = $replyTo;
-
- $includeReport = New-Object $ParameterValueDataType
- $includeReport.Name = "IncludeReport";
- $includeReport.Value = "False";
- $ParameterValues[2] = $includeReport;
-
- $renderFormat = New-Object $ParameterValueDataType
- $renderFormat.Name = "RenderFormat";
- $renderFormat.Value = "MHTML";
- $ParameterValues[3] = $renderFormat;
-
- $priority = New-Object $ParameterValueDataType
- $priority.Name = "Priority";
- $priority.Value = "NORMAL";
- $ParameterValues[4] = $priority;
-
- $subject = New-Object $ParameterValueDataType
- $subject.Name = "Subject";
- $subject.Value = "Your sales report";
- $ParameterValues[5] = $subject;
-
- $comment = New-Object $ParameterValueDataType
- $comment.Name = "Comment";
- $comment.Value = "Here is the link to your report.";
- $ParameterValues[6] = $comment;
-
- $includeLink = New-Object $ParameterValueDataType
- $includeLink.Name = "IncludeLink";
- $includeLink.Value = "True";
- $ParameterValues[7] = $includeLink;
-
- $ExtensionSettings.ParameterValues = $ParameterValues
-
- $subscription = [pscustomobject]@{
- DeliverySettings = $ExtensionSettings
- Description = "Send email to mail@rstools.com"
- EventType = "TimedSubscription"
- IsDataDriven = $false
- MatchData = $matchData.OuterXml
- }
-
- return $subscription
-}
-
-Function Get-NewFileShareSubscription
-{
-
- [xml]$matchData = '2017-07-14T08:00:00.000+01:001truetruetruetruetrue'
-
- $proxy = New-RsWebServiceProxy
- $namespace = $proxy.GetType().NameSpace
-
- $ExtensionSettingsDataType = "$namespace.ExtensionSettings"
- $ParameterValueOrFieldReference = "$namespace.ParameterValueOrFieldReference[]"
- $ParameterValueDataType = "$namespace.ParameterValue"
-
- #Set ExtensionSettings
- $ExtensionSettings = New-Object $ExtensionSettingsDataType
-
- $ExtensionSettings.Extension = "Report Server FileShare"
-
- #Set ParameterValues
- $ParameterValues = New-Object $ParameterValueOrFieldReference -ArgumentList 7
-
- $to = New-Object $ParameterValueDataType
- $to.Name = "PATH";
- $to.Value = "\\unc\path";
- $ParameterValues[0] = $to;
-
- $replyTo = New-Object $ParameterValueDataType
- $replyTo.Name = "FILENAME";
- $replyTo.Value ="Report";
- $ParameterValues[1] = $replyTo;
-
- $includeReport = New-Object $ParameterValueDataType
- $includeReport.Name = "FILEEXTN";
- $includeReport.Value = "True";
- $ParameterValues[2] = $includeReport;
-
- $renderFormat = New-Object $ParameterValueDataType
- $renderFormat.Name = "USERNAME";
- $renderFormat.Value = "user";
- $ParameterValues[3] = $renderFormat;
-
- $priority = New-Object $ParameterValueDataType
- $priority.Name = "RENDER_FORMAT";
- $priority.Value = "PDF";
- $ParameterValues[4] = $priority;
-
- $subject = New-Object $ParameterValueDataType
- $subject.Name = "WRITEMODE";
- $subject.Value = "Overwrite";
- $ParameterValues[5] = $subject;
-
- $comment = New-Object $ParameterValueDataType
- $comment.Name = "DEFAULTCREDENTIALS";
- $comment.Value = "False";
- $ParameterValues[6] = $comment;
-
- $ExtensionSettings.ParameterValues = $ParameterValues
-
- $subscription = [pscustomobject]@{
- DeliverySettings = $ExtensionSettings
- Description = "Shared on \\unc\path"
- EventType = "TimedSubscription"
- IsDataDriven = $false
- MatchData = $matchData.OuterXml
- }
-
- return $subscription
-}
+$reportServerUri = if ($env:PesterServerUrl -eq $null) { 'http://localhost/reportserver' } else { $env:PesterServerUrl }
Function Set-FolderReportDataSource
{
@@ -149,125 +9,107 @@ Function Set-FolderReportDataSource
[string]
$NewFolderPath
)
-
-
- $localResourcesPath = (Get-Item -Path ".\").FullName + '\Tests\CatalogItems\testResources\emptyReport.rdl'
- $null = Write-RsCatalogItem -Path $localResourcesPath -RsFolder $NewFolderPath
- $report = (Get-RsFolderContent -RsFolder $NewFolderPath )| Where-Object TypeName -eq 'Report'
+ $tempProxy = New-RsWebServiceProxy -ReportServerUri $reportServerUri
+
+ # uploading emptyReport.rdl
+ $localResourcesPath = (Get-Item -Path ".\").FullName + '\Tests\CatalogItems\testResources\emptyReport.rdl'
+ $null = Write-RsCatalogItem -Path $localResourcesPath -RsFolder $NewFolderPath -Proxy $tempProxy
+ $report = (Get-RsFolderContent -RsFolder $NewFolderPath -Proxy $tempProxy)| Where-Object TypeName -eq 'Report'
+
+ # uploading UnDataset.rsd
$localResourcesPath = (Get-Item -Path ".\").FullName + '\Tests\CatalogItems\testResources\UnDataset.rsd'
- $null = Write-RsCatalogItem -Path $localResourcesPath -RsFolder $NewFolderPath
- $dataSet = (Get-RsFolderContent -RsFolder $NewFolderPath ) | Where-Object TypeName -eq 'DataSet'
+ $null = Write-RsCatalogItem -Path $localResourcesPath -RsFolder $NewFolderPath -Proxy $tempProxy
+ $dataSet = (Get-RsFolderContent -RsFolder $NewFolderPath -Proxy $tempProxy) | Where-Object TypeName -eq 'DataSet'
$DataSetPath = $NewFolderPath + '/UnDataSet'
-
+
+ # creating a shared data source with Dummy credentials
$newRSDSName = "DataSource"
$newRSDSExtension = "SQL"
$newRSDSConnectionString = "Initial Catalog=DB; Data Source=Instance"
$newRSDSCredentialRetrieval = "Store"
- #Dummy credentials
$Pass = ConvertTo-SecureString -String "123" -AsPlainText -Force
$newRSDSCredential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList "sql", $Pass
- $null = New-RsDataSource -RsFolder $NewFolderPath -Name $newRSDSName -Extension $newRSDSExtension -ConnectionString $newRSDSConnectionString -CredentialRetrieval $newRSDSCredentialRetrieval -DatasourceCredentials $newRSDSCredential
+ $null = New-RsDataSource -RsFolder $NewFolderPath -Name $newRSDSName -Extension $newRSDSExtension -ConnectionString $newRSDSConnectionString -CredentialRetrieval $newRSDSCredentialRetrieval -DatasourceCredentials $newRSDSCredential -Proxy $tempProxy
$DataSourcePath = "$NewFolderPath/$newRSDSName"
- $RsDataSet = Get-RsItemReference -Path $report.Path | Where-Object ReferenceType -eq 'DataSet'
- $RsDataSource = Get-RsItemReference -Path $report.Path | Where-Object ReferenceType -eq 'DataSource'
- $RsDataSetSource = Get-RsItemReference -Path $DataSetPath | Where-Object ReferenceType -eq 'DataSource'
+ # retrieving embedded dataset and datasources
+ $RsDataSet = Get-RsItemReference -Path $report.Path -Proxy $tempProxy | Where-Object ReferenceType -eq 'DataSet'
+ $RsDataSource = Get-RsItemReference -Path $report.Path -Proxy $tempProxy | Where-Object ReferenceType -eq 'DataSource'
+ $RsDataSetSource = Get-RsItemReference -Path $DataSetPath -Proxy $tempProxy | Where-Object ReferenceType -eq 'DataSource'
- #Set data source and data set for all objects
- $null = Set-RsDataSourceReference -Path $DataSetPath -DataSourceName $RsDataSetSource.Name -DataSourcePath $DataSourcePath
- $null = Set-RsDataSourceReference -Path $report.Path -DataSourceName $RsDataSource.Name -DataSourcePath $DataSourcePath
- $null = Set-RsDataSetReference -Path $report.Path -DataSetName $RsDataSet.Name -DataSetPath $dataSet.Path
+ # Set data source and data set for all objects
+ $null = Set-RsDataSourceReference -Path $DataSetPath -DataSourceName $RsDataSetSource.Name -DataSourcePath $DataSourcePath -Proxy $tempProxy
+ $null = Set-RsDataSourceReference -Path $report.Path -DataSourceName $RsDataSource.Name -DataSourcePath $DataSourcePath -Proxy $tempProxy
+ $null = Set-RsDataSetReference -Path $report.Path -DataSetName $RsDataSet.Name -DataSetPath $dataSet.Path -Proxy $tempProxy
return $report
}
Describe "Get-RsSubscription" {
- Context "Get-RsSubscription without parameters"{
- $folderName = 'SutGetRsItemReference_MinParameters' + [guid]::NewGuid()
- $null = New-RsFolder -Path / -FolderName $folderName
- $folderPath = '/' + $folderName
+ $folderPath = ''
+ $newReport = $null
- $newReport = Set-FolderReportDataSource($folderPath)
+ BeforeEach {
+ $folderName = 'SutGetRsItemReference_MinParameters' + [guid]::NewGuid()
+ $null = New-RsFolder -Path / -FolderName $folderName -ReportServerUri $reportServerUri
+ $folderPath = '/' + $folderName
- $subscription = Get-NewFileShareSubscription
+ # upload test reports and initialize data sources/data sets
+ $newReport = Set-FolderReportDataSource($folderPath)
- Set-RsSubscription -Subscription $subscription -Path $newReport.Path
-
- $reportSubscriptions = Get-RsSubscription -Path $newReport.Path
-
- It "Should found a reference to a subscription" {
- @($reportSubscriptions).Count | Should Be 1
- $reportSubscriptions.Report | Should Be "emptyReport"
- }
- Remove-RsCatalogItem -RsFolder $folderPath
- }
-
- Context "Get-RsSubscription with Proxy parameter"{
- $folderName = 'SutGetRsItemReference_MinParameters' + [guid]::NewGuid()
- $null = New-RsFolder -Path / -FolderName $folderName
- $folderPath = '/' + $folderName
-
- $proxy = New-RsWebServiceProxy
-
- $newReport = Set-FolderReportDataSource($folderPath)
+ # create a test subscription
+ New-RsSubscription -ReportServerUri $reportServerUri -RsItem $newReport.Path -DeliveryMethod FileShare -Schedule (New-RsScheduleXml) -FileSharePath '\\unc\path' -Filename 'Report' -FileWriteMode Overwrite -RenderFormat PDF
+ }
- $subscription = Get-NewFileShareSubscription
-
- Set-RsSubscription -Subscription $subscription -Path $newReport.Path
-
- $reportSubscriptions = Get-RsSubscription -Path $newReport.Path -Proxy $proxy
-
- It "Should found a reference to a subscription" {
- @($reportSubscriptions).Count | Should Be 1
- $reportSubscriptions.Report | Should Be "emptyReport"
- }
- Remove-RsCatalogItem -RsFolder $folderPath
+ Context "Get-RsSubscription with Proxy parameter"{
+ It "Should found a reference to a subscription" {
+ $proxy = New-RsWebServiceProxy -ReportServerUri $reportServerUri
+ $reportSubscriptions = Get-RsSubscription -RsItem $newReport.Path -Proxy $proxy
+
+ @($reportSubscriptions).Count | Should Be 1
+ $reportSubscriptions.Report | Should Be "emptyReport"
+ $reportSubscriptions.EventType | Should Be "TimedSubscription"
+ $reportSubscriptions.IsDataDriven | Should Be $false
+ $reportSubscriptions.DeliverySettings.Extension | Should Be "Report Server FileShare"
+ ($reportSubscriptions.DeliverySettings.ParameterValues | Where-Object { $_.Name -eq 'Path' }).Value | Should Be "\\unc\path"
+ ($reportSubscriptions.DeliverySettings.ParameterValues | Where-Object { $_.Name -eq 'FileName' }).Value | Should Be "Report"
+ ($reportSubscriptions.DeliverySettings.ParameterValues | Where-Object { $_.Name -eq 'WriteMode' }).Value | Should Be "Overwrite"
+ ($reportSubscriptions.DeliverySettings.ParameterValues | Where-Object { $_.Name -eq 'DefaultCredentials' }).Value | Should Be True
}
-
- Context "Get-RsSubscription with ReportServerUri Parameter"{
- $folderName = 'SutGetRsItemReference_MinParameters' + [guid]::NewGuid()
- $null = New-RsFolder -Path / -FolderName $folderName
- $folderPath = '/' + $folderName
-
- $reportServerUri = 'http://localhost/reportserver'
-
- $newReport = Set-FolderReportDataSource($folderPath)
-
- $subscription = Get-NewFileShareSubscription
-
- Set-RsSubscription -Subscription $subscription -Path $newReport.Path
-
- $reportSubscriptions = Get-RsSubscription -ReportServerUri $ReportServerUri -Path $newReport.Path
-
- It "Should found a reference to a subscription" {
- @($reportSubscriptions).Count | Should Be 1
- $reportSubscriptions.Report | Should Be "emptyReport"
- }
- Remove-RsCatalogItem -ReportServerUri $ReportServerUri -RsFolder $folderPath
+ }
+
+ Context "Get-RsSubscription with ReportServerUri Parameter"{
+ It "Should found a reference to a subscription" {
+ $reportSubscriptions = Get-RsSubscription -RsItem $newReport.Path -ReportServerUri $reportServerUri
+
+ @($reportSubscriptions).Count | Should Be 1
+ $reportSubscriptions.Report | Should Be "emptyReport"
+ $reportSubscriptions.EventType | Should Be "TimedSubscription"
+ $reportSubscriptions.IsDataDriven | Should Be $false
+ $reportSubscriptions.DeliverySettings.Extension | Should Be "Report Server FileShare"
+ ($reportSubscriptions.DeliverySettings.ParameterValues | Where-Object { $_.Name -eq 'Path' }).Value | Should Be "\\unc\path"
+ ($reportSubscriptions.DeliverySettings.ParameterValues | Where-Object { $_.Name -eq 'FileName' }).Value | Should Be "Report"
+ ($reportSubscriptions.DeliverySettings.ParameterValues | Where-Object { $_.Name -eq 'WriteMode' }).Value | Should Be "Overwrite"
+ ($reportSubscriptions.DeliverySettings.ParameterValues | Where-Object { $_.Name -eq 'DefaultCredentials' }).Value | Should Be True
}
-
- Context "Get-RsSubscription with ReportServerUri and Proxy Parameter"{
- $folderName = 'SutGetRsItemReference_MinParameters' + [guid]::NewGuid()
- $null = New-RsFolder -Path / -FolderName $folderName
- $folderPath = '/' + $folderName
-
- $reportServerUri = 'http://localhost/reportserver'
- $proxy = New-RsWebServiceProxy
-
- $newReport = Set-FolderReportDataSource($folderPath)
-
- $subscription = Get-NewFileShareSubscription
-
- Set-RsSubscription -Subscription $subscription -Path $newReport.Path
-
- $reportSubscriptions = Get-RsSubscription -ReportServerUri $ReportServerUri -Path $newReport.Path -Proxy $proxy
-
- It "Should found a reference to a subscription" {
- @($reportSubscriptions).Count | Should Be 1
- $reportSubscriptions.Report | Should Be "emptyReport"
- }
- Remove-RsCatalogItem -ReportServerUri $ReportServerUri -RsFolder $folderPath
+ }
+
+ Context "Get-RsSubscription with ReportServerUri and Proxy Parameter"{
+ It "Should found a reference to a subscription" {
+ $proxy = New-RsWebServiceProxy -ReportServerUri $reportServerUri
+ $reportSubscriptions = Get-RsSubscription -RsItem $newReport.Path -Proxy $proxy -ReportServerUri $reportServerUri
+
+ @($reportSubscriptions).Count | Should Be 1
+ $reportSubscriptions.Report | Should Be "emptyReport"
+ $reportSubscriptions.EventType | Should Be "TimedSubscription"
+ $reportSubscriptions.IsDataDriven | Should Be $false
+ $reportSubscriptions.DeliverySettings.Extension | Should Be "Report Server FileShare"
+ ($reportSubscriptions.DeliverySettings.ParameterValues | Where-Object { $_.Name -eq 'Path' }).Value | Should Be "\\unc\path"
+ ($reportSubscriptions.DeliverySettings.ParameterValues | Where-Object { $_.Name -eq 'FileName' }).Value | Should Be "Report"
+ ($reportSubscriptions.DeliverySettings.ParameterValues | Where-Object { $_.Name -eq 'WriteMode' }).Value | Should Be "Overwrite"
+ ($reportSubscriptions.DeliverySettings.ParameterValues | Where-Object { $_.Name -eq 'DefaultCredentials' }).Value | Should Be True
}
+ }
}
\ No newline at end of file
diff --git a/Tests/CatalogItems/Import-RsSubscriptionXml.Tests.ps1 b/Tests/CatalogItems/Import-RsSubscriptionXml.Tests.ps1
index 21fff302..f9578d60 100644
--- a/Tests/CatalogItems/Import-RsSubscriptionXml.Tests.ps1
+++ b/Tests/CatalogItems/Import-RsSubscriptionXml.Tests.ps1
@@ -1,87 +1,13 @@
# Copyright (c) 2016 Microsoft Corporation. All Rights Reserved.
# Licensed under the MIT License (MIT)
-#Not in use right now - need email configuration on the report server
-Function Get-NewSubscription
-{
-
- [xml]$matchData = '2017-07-14T08:00:00.000+01:001truetruetruetruetrue'
-
- $proxy = New-RsWebServiceProxy
- $namespace = $proxy.GetType().NameSpace
-
- $ExtensionSettingsDataType = "$namespace.ExtensionSettings"
- $ParameterValueOrFieldReference = "$namespace.ParameterValueOrFieldReference[]"
- $ParameterValueDataType = "$namespace.ParameterValue"
-
- #Set ExtensionSettings
- $ExtensionSettings = New-Object $ExtensionSettingsDataType
-
- $ExtensionSettings.Extension = "Report Server Email"
-
- #Set ParameterValues
- $ParameterValues = New-Object $ParameterValueOrFieldReference -ArgumentList 8
-
- $to = New-Object $ParameterValueDataType
- $to.Name = "TO";
- $to.Value = "mail@rstools.com";
- $ParameterValues[0] = $to;
-
- $replyTo = New-Object $ParameterValueDataType
- $replyTo.Name = "ReplyTo";
- $replyTo.Value ="dank@rstools.com";
- $ParameterValues[1] = $replyTo;
-
- $includeReport = New-Object $ParameterValueDataType
- $includeReport.Name = "IncludeReport";
- $includeReport.Value = "False";
- $ParameterValues[2] = $includeReport;
-
- $renderFormat = New-Object $ParameterValueDataType
- $renderFormat.Name = "RenderFormat";
- $renderFormat.Value = "MHTML";
- $ParameterValues[3] = $renderFormat;
-
- $priority = New-Object $ParameterValueDataType
- $priority.Name = "Priority";
- $priority.Value = "NORMAL";
- $ParameterValues[4] = $priority;
-
- $subject = New-Object $ParameterValueDataType
- $subject.Name = "Subject";
- $subject.Value = "Your sales report";
- $ParameterValues[5] = $subject;
-
- $comment = New-Object $ParameterValueDataType
- $comment.Name = "Comment";
- $comment.Value = "Here is the link to your report.";
- $ParameterValues[6] = $comment;
-
- $includeLink = New-Object $ParameterValueDataType
- $includeLink.Name = "IncludeLink";
- $includeLink.Value = "True";
- $ParameterValues[7] = $includeLink;
-
- $ExtensionSettings.ParameterValues = $ParameterValues
-
- $subscription = [pscustomobject]@{
- DeliverySettings = $ExtensionSettings
- Description = "Send email to mail@rstools.com"
- EventType = "TimedSubscription"
- IsDataDriven = $false
- MatchData = $matchData.OuterXml
- Values = $null
- }
-
- return $subscription
-}
+$reportServerUri = if ($env:PesterServerUrl -eq $null) { 'http://localhost/reportserver' } else { $env:PesterServerUrl }
-Function Get-NewFileShareSubscription
+Function New-InMemoryFileShareSubscription
{
-
[xml]$matchData = '2017-07-14T08:00:00.000+01:001truetruetruetruetrue'
-
- $proxy = New-RsWebServiceProxy
+
+ $proxy = New-RsWebServiceProxy -ReportServerUri $reportServerUri
$namespace = $proxy.GetType().NameSpace
$ExtensionSettingsDataType = "$namespace.ExtensionSettings"
@@ -90,7 +16,6 @@ Function Get-NewFileShareSubscription
#Set ExtensionSettings
$ExtensionSettings = New-Object $ExtensionSettingsDataType
-
$ExtensionSettings.Extension = "Report Server FileShare"
#Set ParameterValues
@@ -138,7 +63,7 @@ Function Get-NewFileShareSubscription
Description = "Shared on \\unc\path"
EventType = "TimedSubscription"
IsDataDriven = $false
- MatchData = $matchData.OuterXml
+ MatchData = $matchData.OuterXml
Values = $null
}
@@ -146,17 +71,12 @@ Function Get-NewFileShareSubscription
}
Describe 'Import-RsSubscriptionXml' {
-
- $TestPath = 'TestDrive:\Subscription.xml'
- Get-NewFileShareSubscription | Export-RsSubscriptionXml $TestPath
-
-
Context 'Import-RsSubscriptionXml' {
-
- Get-NewFileShareSubscription | Export-RsSubscriptionXml $TestPath
- $Result = Import-RsSubscriptionXml $TestPath
-
It 'Should import a subscription' {
+ $TestPath = 'TestDrive:\Subscription.xml'
+ New-InMemoryFileShareSubscription | Export-RsSubscriptionXml $TestPath
+ $Result = Import-RsSubscriptionXml $TestPath -ReportServerUri $reportServerUri
+
$Result.Description | Should Be 'Shared on \\unc\path'
}
}
diff --git a/Tests/CatalogItems/New-RsDataSource.Tests.ps1 b/Tests/CatalogItems/New-RsDataSource.Tests.ps1
index f3444edc..975ba78c 100644
--- a/Tests/CatalogItems/New-RsDataSource.Tests.ps1
+++ b/Tests/CatalogItems/New-RsDataSource.Tests.ps1
@@ -36,7 +36,7 @@ Describe "New-RsDataSource" {
}
# Removing folders used for testing
- Remove-RsCatalogItem -RsFolder $dataSourcePath
+ Remove-RsCatalogItem -RsFolder $dataSourcePath -Confirm:$false
}
Context "Create RsDataSource with ReportServerUri parameter"{
@@ -51,7 +51,7 @@ Describe "New-RsDataSource" {
{Get-RsDataSource -Path $dataSourcePath } | Should not throw
}
# Removing folders used for testing
- Remove-RsCatalogItem -RsFolder $dataSourcePath
+ Remove-RsCatalogItem -RsFolder $dataSourcePath -Confirm:$false
}
Context "Create RsDataSource with Proxy parameter"{
@@ -66,7 +66,7 @@ Describe "New-RsDataSource" {
{Get-RsDataSource -Path $dataSourcePath } | Should not throw
}
# Removing folders used for testing
- Remove-RsCatalogItem -RsFolder $dataSourcePath
+ Remove-RsCatalogItem -RsFolder $dataSourcePath -Confirm:$false
}
Context "Create RsDataSource with connection string parameter"{
@@ -85,7 +85,7 @@ Describe "New-RsDataSource" {
$dataSource.ConnectString | Should Be $connectionString
}
# Removing folders used for testing
- Remove-RsCatalogItem -RsFolder $dataSourcePath
+ Remove-RsCatalogItem -RsFolder $dataSourcePath -Confirm:$false
}
Context "Create RsDataSource with Proxy and ReportServerUri parameters"{
@@ -101,7 +101,7 @@ Describe "New-RsDataSource" {
{Get-RsDataSource -Path $dataSourcePath } | Should not throw
}
# Removing folders used for testing
- Remove-RsCatalogItem -RsFolder $dataSourcePath
+ Remove-RsCatalogItem -RsFolder $dataSourcePath -Confirm:$false
}
Context "Create RsDataSource with unsupported RsDataSource Extension validation"{
@@ -143,7 +143,7 @@ Describe "New-RsDataSource" {
{Get-RsDataSource -Path $dataSourcePath } | Should not throw
}
# Removing folders used for testing
- Remove-RsCatalogItem -RsFolder $dataSourcePath
+ Remove-RsCatalogItem -RsFolder $dataSourcePath -Confirm:$false
}
# Impersonate parameter doesn´t change
@@ -164,7 +164,7 @@ Describe "New-RsDataSource" {
# $dataSource.ImpersonateUser | Should Be $true
# }
# # Removing folders used for testing
- # Remove-RsCatalogItem -RsFolder $dataSourcePath
+ # Remove-RsCatalogItem -RsFolder $dataSourcePath -Confirm:$false
# }
Context "Create RsDataSource with Windows Credentials Parameter"{
@@ -185,7 +185,7 @@ Describe "New-RsDataSource" {
$dataSource.WindowsCredentials | Should Be $true
}
# Removing folders used for testing
- Remove-RsCatalogItem -RsFolder $dataSourcePath
+ Remove-RsCatalogItem -RsFolder $dataSourcePath -Confirm:$false
}
Context "Create RsDataSource with Prompt Credentials Retrieval"{
@@ -200,7 +200,7 @@ Describe "New-RsDataSource" {
{Get-RsDataSource -Path $dataSourcePath } | Should not throw
}
# Removing folders used for testing
- Remove-RsCatalogItem -RsFolder $dataSourcePath
+ Remove-RsCatalogItem -RsFolder $dataSourcePath -Confirm:$false
}
Context "Create RsDataSource and Overwrite it"{
@@ -219,7 +219,7 @@ Describe "New-RsDataSource" {
$dataSource.Count | Should Be 1
}
# Removing folders used for testing
- Remove-RsCatalogItem -RsFolder $dataSourcePath
+ Remove-RsCatalogItem -RsFolder $dataSourcePath -Confirm:$false
}
Context "Create RsDataSource with description"{
@@ -243,6 +243,6 @@ Describe "New-RsDataSource" {
}
# Removing folders used for testing
- Remove-RsCatalogItem -RsFolder $dataSourcePath
+ Remove-RsCatalogItem -RsFolder $dataSourcePath -Confirm:$false
}
}
\ No newline at end of file
diff --git a/Tests/CatalogItems/New-RsFolder.Tests.ps1 b/Tests/CatalogItems/New-RsFolder.Tests.ps1
index 4926e709..e06270fc 100644
--- a/Tests/CatalogItems/New-RsFolder.Tests.ps1
+++ b/Tests/CatalogItems/New-RsFolder.Tests.ps1
@@ -12,7 +12,7 @@ Describe "New-RsFolder" {
$folderCount | Should Be 1
}
# Removing folders used for testing
- Remove-RsCatalogItem -ReportServerUri 'http://localhost/reportserver' -RsFolder $folderPath
+ Remove-RsCatalogItem -ReportServerUri 'http://localhost/reportserver' -RsFolder $folderPath -Confirm:$false
}
Context "Create a subfolder"{
@@ -37,7 +37,7 @@ Describe "New-RsFolder" {
$subFolderCount | Should be 1
}
# Removing folders used for testing
- Remove-RsCatalogItem -ReportServerUri 'http://localhost/reportserver' -RsFolder $folderPath
+ Remove-RsCatalogItem -ReportServerUri 'http://localhost/reportserver' -RsFolder $folderPath -Confirm:$false
}
Context "Create a folder with proxy"{
@@ -54,7 +54,7 @@ Describe "New-RsFolder" {
$folderCount | Should be 1
}
# Removing folders used for testing
- Remove-RsCatalogItem -ReportServerUri 'http://localhost/reportserver' -RsFolder $folderPath
+ Remove-RsCatalogItem -ReportServerUri 'http://localhost/reportserver' -RsFolder $folderPath -Confirm:$false
}
Context "Create a folder with ReportServerUri"{
@@ -71,7 +71,7 @@ Describe "New-RsFolder" {
$folderCount | Should Be 1
}
# Removing folders used for testing
- Remove-RsCatalogItem -ReportServerUri 'http://localhost/reportserver' -RsFolder $folderPath
+ Remove-RsCatalogItem -ReportServerUri 'http://localhost/reportserver' -RsFolder $folderPath -Confirm:$false
}
Context "Create a folder with all the parameters except credentials"{
@@ -89,6 +89,6 @@ Describe "New-RsFolder" {
$folderCount | Should Be 1
}
# Removing folders used for testing
- Remove-RsCatalogItem -ReportServerUri 'http://localhost/reportserver' -RsFolder $folderPath
+ Remove-RsCatalogItem -ReportServerUri 'http://localhost/reportserver' -RsFolder $folderPath -Confirm:$false
}
}
\ No newline at end of file
diff --git a/Tests/CatalogItems/New-RsSubscription.Tests.ps1 b/Tests/CatalogItems/New-RsSubscription.Tests.ps1
index 987319eb..cc06c5a0 100644
--- a/Tests/CatalogItems/New-RsSubscription.Tests.ps1
+++ b/Tests/CatalogItems/New-RsSubscription.Tests.ps1
@@ -1,41 +1,47 @@
# Copyright (c) 2016 Microsoft Corporation. All Rights Reserved.
# Licensed under the MIT License (MIT)
+$reportServerUri = if ($env:PesterServerUrl -eq $null) { 'http://localhost/reportserver' } else { $env:PesterServerUrl }
+
Function Set-FolderReportDataSource {
param (
[string]
$NewFolderPath
)
-
- $localResourcesPath = (Get-Item -Path ".\").FullName + '\Tests\CatalogItems\testResources\emptyReport.rdl'
- $null = Write-RsCatalogItem -Path $localResourcesPath -RsFolder $NewFolderPath
- $report = (Get-RsFolderContent -RsFolder $NewFolderPath )| Where-Object TypeName -eq 'Report'
+ $tempProxy = New-RsWebServiceProxy -ReportServerUri $reportServerUri
+
+ # uploading emptyReport.rdl
+ $localResourcesPath = (Get-Item -Path ".\").FullName + '\Tests\CatalogItems\testResources\emptyReport.rdl'
+ $null = Write-RsCatalogItem -Path $localResourcesPath -RsFolder $NewFolderPath -Proxy $tempProxy
+ $report = (Get-RsFolderContent -RsFolder $NewFolderPath -Proxy $tempProxy)| Where-Object TypeName -eq 'Report'
+
+ # uploading UnDataset.rsd
$localResourcesPath = (Get-Item -Path ".\").FullName + '\Tests\CatalogItems\testResources\UnDataset.rsd'
- $null = Write-RsCatalogItem -Path $localResourcesPath -RsFolder $NewFolderPath
- $dataSet = (Get-RsFolderContent -RsFolder $NewFolderPath ) | Where-Object TypeName -eq 'DataSet'
+ $null = Write-RsCatalogItem -Path $localResourcesPath -RsFolder $NewFolderPath -Proxy $tempProxy
+ $dataSet = (Get-RsFolderContent -RsFolder $NewFolderPath -Proxy $tempProxy) | Where-Object TypeName -eq 'DataSet'
$DataSetPath = $NewFolderPath + '/UnDataSet'
-
+
+ # creating a shared data source with Dummy credentials
$newRSDSName = "DataSource"
$newRSDSExtension = "SQL"
$newRSDSConnectionString = "Initial Catalog=DB; Data Source=Instance"
$newRSDSCredentialRetrieval = "Store"
-
- #Dummy credentials
$Pass = ConvertTo-SecureString -String "123" -AsPlainText -Force
$newRSDSCredential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList "sql", $Pass
- $null = New-RsDataSource -RsFolder $NewFolderPath -Name $newRSDSName -Extension $newRSDSExtension -ConnectionString $newRSDSConnectionString -CredentialRetrieval $newRSDSCredentialRetrieval -DatasourceCredentials $newRSDSCredential
+ $null = New-RsDataSource -RsFolder $NewFolderPath -Name $newRSDSName -Extension $newRSDSExtension -ConnectionString $newRSDSConnectionString -CredentialRetrieval $newRSDSCredentialRetrieval -DatasourceCredentials $newRSDSCredential -Proxy $tempProxy
$DataSourcePath = "$NewFolderPath/$newRSDSName"
- $RsDataSet = Get-RsItemReference -Path $report.Path | Where-Object ReferenceType -eq 'DataSet'
- $RsDataSource = Get-RsItemReference -Path $report.Path | Where-Object ReferenceType -eq 'DataSource'
- $RsDataSetSource = Get-RsItemReference -Path $DataSetPath | Where-Object ReferenceType -eq 'DataSource'
+ # retrieving embedded dataset and datasources
+ $RsDataSet = Get-RsItemReference -Path $report.Path -Proxy $tempProxy | Where-Object ReferenceType -eq 'DataSet'
+ $RsDataSource = Get-RsItemReference -Path $report.Path -Proxy $tempProxy | Where-Object ReferenceType -eq 'DataSource'
+ $RsDataSetSource = Get-RsItemReference -Path $DataSetPath -Proxy $tempProxy | Where-Object ReferenceType -eq 'DataSource'
- #Set data source and data set for all objects
- $null = Set-RsDataSourceReference -Path $DataSetPath -DataSourceName $RsDataSetSource.Name -DataSourcePath $DataSourcePath
- $null = Set-RsDataSourceReference -Path $report.Path -DataSourceName $RsDataSource.Name -DataSourcePath $DataSourcePath
- $null = Set-RsDataSetReference -Path $report.Path -DataSetName $RsDataSet.Name -DataSetPath $dataSet.Path
+ # Set data source and data set for all objects
+ $null = Set-RsDataSourceReference -Path $DataSetPath -DataSourceName $RsDataSetSource.Name -DataSourcePath $DataSourcePath -Proxy $tempProxy
+ $null = Set-RsDataSourceReference -Path $report.Path -DataSourceName $RsDataSource.Name -DataSourcePath $DataSourcePath -Proxy $tempProxy
+ $null = Set-RsDataSetReference -Path $report.Path -DataSetName $RsDataSet.Name -DataSetPath $dataSet.Path -Proxy $tempProxy
return $report
}
@@ -46,99 +52,55 @@ Function New-RsScheduleXML {
Describe 'New-RsSubscription' {
+ $folderPath = ''
+ $newReport = $null
- Context 'New-RsSubscription FileShare Subscription' {
-
- $folderName = 'SutGetRsItemReference_MinParameters' + [guid]::NewGuid()
- $null = New-RsFolder -Path / -FolderName $folderName
+ BeforeEach {
+ $folderName = 'SutNewRsSubscription_' + [guid]::NewGuid()
+ $null = New-RsFolder -Path / -FolderName $folderName -ReportServerUri $reportServerUri
$folderPath = '/' + $folderName
-
$newReport = Set-FolderReportDataSource($folderPath)
+ }
- New-RsSubscription -Path $newReport.Path -Destination 'FileShare' -DestinationPath '\\some\path' -FileName 'file.pdf' -RenderFormat PDF -Schedule (New-RsScheduleXML)
-
- $reportSubscriptions = Get-RsSubscription -Path $newReport.Path
-
- It 'Should create a new subscription' {
- @($reportSubscriptions).Count | Should Be 1
- $reportSubscriptions.Report | Should Be "emptyReport"
- $reportSubscriptions.EventType | Should Be "TimedSubscription"
- $reportSubscriptions.IsDataDriven | Should Be $false
- }
-
- Remove-RsCatalogItem -RsFolder $folderPath
+ AfterEach {
+ Remove-RsCatalogItem -RsFolder $folderPath -ReportServerUri $reportServerUri -Confirm:$false -ErrorAction Continue
}
Context 'New-RsSubscription FileShare Subscription with Proxy parameter' {
+ It 'Should create a new fileshare subscription' {
+ $proxy = New-RsWebServiceProxy -ReportServerUri $reportServerUri
+ New-RsSubscription -RsItem $newReport.Path -DeliveryMethod 'FileShare' -FileSharePath '\\some\path' -FileName 'file.pdf' -RenderFormat PDF -Schedule (New-RsScheduleXML) -Proxy $proxy
+ $reportSubscriptions = Get-RsSubscription -Path $newReport.Path -ReportServerUri $reportServerUri
- $folderName = 'SutGetRsItemReference_MinParameters' + [guid]::NewGuid()
- $null = New-RsFolder -Path / -FolderName $folderName
- $folderPath = '/' + $folderName
-
- $proxy = New-RsWebServiceProxy
-
- $newReport = Set-FolderReportDataSource($folderPath)
-
- New-RsSubscription -Path $newReport.Path -Destination 'FileShare' -DestinationPath '\\some\path' -FileName 'file.pdf' -RenderFormat PDF -Schedule (New-RsScheduleXML) -Proxy $proxy
-
- $reportSubscriptions = Get-RsSubscription -Path $newReport.Path
-
- It 'Should create a new subscription' {
@($reportSubscriptions).Count | Should Be 1
$reportSubscriptions.Report | Should Be "emptyReport"
$reportSubscriptions.EventType | Should Be "TimedSubscription"
$reportSubscriptions.IsDataDriven | Should Be $false
}
-
- Remove-RsCatalogItem -RsFolder $folderPath
}
-
- Context 'New-RsSubscription FileShare Subscription with ReportServerUri Parameter' {
-
- $folderName = 'SutGetRsItemReference_MinParameters' + [guid]::NewGuid()
- $null = New-RsFolder -Path / -FolderName $folderName
- $folderPath = '/' + $folderName
- $reportServerUri = 'http://localhost/reportserver'
-
- $newReport = Set-FolderReportDataSource($folderPath)
-
- New-RsSubscription -Path $newReport.Path -Destination 'FileShare' -DestinationPath '\\some\path' -FileName 'file.pdf' -RenderFormat PDF -Schedule (New-RsScheduleXML) -ReportServerUri $ReportServerUri
-
- $reportSubscriptions = Get-RsSubscription -Path $newReport.Path
+ Context 'New-RsSubscription FileShare Subscription with ReportServerUri Parameter' {
+ It 'Should create a new fileshare subscription' {
+ New-RsSubscription -RsItem $newReport.Path -DeliveryMethod 'FileShare' -FileSharePath '\\some\path' -FileName 'file.pdf' -RenderFormat PDF -Schedule (New-RsScheduleXML) -ReportServerUri $reportServerUri
+ $reportSubscriptions = Get-RsSubscription -Path $newReport.Path -ReportServerUri $reportServerUri
- It 'Should create a new subscription' {
@($reportSubscriptions).Count | Should Be 1
$reportSubscriptions.Report | Should Be "emptyReport"
$reportSubscriptions.EventType | Should Be "TimedSubscription"
$reportSubscriptions.IsDataDriven | Should Be $false
}
-
- Remove-RsCatalogItem -RsFolder $folderPath
}
Context 'New-RsSubscription with ReportServerUri and Proxy Parameter' {
-
- $folderName = 'SutGetRsItemReference_MinParameters' + [guid]::NewGuid()
- $null = New-RsFolder -Path / -FolderName $folderName
- $folderPath = '/' + $folderName
-
- $reportServerUri = 'http://localhost/reportserver'
- $proxy = New-RsWebServiceProxy
-
- $newReport = Set-FolderReportDataSource($folderPath)
-
- New-RsSubscription -Path $newReport.Path -Destination 'FileShare' -DestinationPath '\\some\path' -FileName 'file.pdf' -RenderFormat PDF -Schedule (New-RsScheduleXML) -ReportServerUri $ReportServerUri -Proxy $proxy
-
- $reportSubscriptions = Get-RsSubscription -Path $newReport.Path
-
It 'Should create a new subscription' {
+ $proxy = New-RsWebServiceProxy -ReportServerUri $reportServerUri
+ New-RsSubscription -RsItem $newReport.Path -DeliveryMethod 'FileShare' -FileSharePath '\\some\path' -FileName 'file.pdf' -RenderFormat PDF -Schedule (New-RsScheduleXML) -ReportServerUri $reportServerUri -Proxy $proxy
+ $reportSubscriptions = Get-RsSubscription -Path $newReport.Path -ReportServerUri $reportServerUri
+
@($reportSubscriptions).Count | Should Be 1
$reportSubscriptions.Report | Should Be "emptyReport"
$reportSubscriptions.EventType | Should Be "TimedSubscription"
$reportSubscriptions.IsDataDriven | Should Be $false
}
-
- Remove-RsCatalogItem -RsFolder $folderPath
}
}
\ No newline at end of file
diff --git a/Tests/CatalogItems/Out-RsCatalogItem.Tests.ps1 b/Tests/CatalogItems/Out-RsCatalogItem.Tests.ps1
index 2f0a51d1..539cbaeb 100644
--- a/Tests/CatalogItems/Out-RsCatalogItem.Tests.ps1
+++ b/Tests/CatalogItems/Out-RsCatalogItem.Tests.ps1
@@ -47,7 +47,7 @@ Describe "Out-RsCatalogItem" {
$localDataSourceDownloadedPath = $currentLocalPath + '\' + $localFolderName +'\' + 'SutWriteRsFolderContent_DataSource.rsds'
}
Remove-Item $destinationPath -Confirm:$false -Recurse
- Remove-RsCatalogItem -RsFolder $folderPath
+ Remove-RsCatalogItem -RsFolder $folderPath -Confirm:$false
}
Context "Download a report with ReportServerUri Parameter"{
@@ -76,7 +76,7 @@ Describe "Out-RsCatalogItem" {
Remove-Item $localReportDownloadedPath
}
Remove-Item $destinationPath -Confirm:$false -Recurse
- Remove-RsCatalogItem -RsFolder $folderPath
+ Remove-RsCatalogItem -RsFolder $folderPath -Confirm:$false
}
Context "Download a report with Proxy and ReportServerUr Parameter"{
@@ -106,7 +106,7 @@ Describe "Out-RsCatalogItem" {
Remove-Item $localReportDownloadedPath
}
Remove-Item $destinationPath -Confirm:$false -Recurse
- Remove-RsCatalogItem -RsFolder $folderPath
+ Remove-RsCatalogItem -RsFolder $folderPath -Confirm:$false
}
Context "Download a report with Proxy Parameter"{
@@ -135,7 +135,7 @@ Describe "Out-RsCatalogItem" {
Remove-Item $localReportDownloadedPath
}
Remove-Item $destinationPath -Confirm:$false -Recurse
- Remove-RsCatalogItem -RsFolder $folderPath
+ Remove-RsCatalogItem -RsFolder $folderPath -Confirm:$false
}
}
diff --git a/Tests/CatalogItems/Out-RsFolderContent.Tests.ps1 b/Tests/CatalogItems/Out-RsFolderContent.Tests.ps1
index c5bddb1f..63dfa3e7 100644
--- a/Tests/CatalogItems/Out-RsFolderContent.Tests.ps1
+++ b/Tests/CatalogItems/Out-RsFolderContent.Tests.ps1
@@ -32,7 +32,7 @@ Describe "Out-RsFolderContent" {
}
# Removing local folder content downloaded from report server used for testing
Remove-Item $destinationPath -Confirm:$false -Recurse
- Remove-RsCatalogItem -RsFolder $rsFolderPath
+ Remove-RsCatalogItem -RsFolder $rsFolderPath -Confirm:$false
}
Context "Out-RsFolderContent with ReportServerUri Parameter"{
@@ -55,7 +55,7 @@ Describe "Out-RsFolderContent" {
}
# Removing local folder content downloaded from report server used for testing
Remove-Item $destinationPath -Confirm:$false -Recurse
- Remove-RsCatalogItem -RsFolder $rsFolderPath
+ Remove-RsCatalogItem -RsFolder $rsFolderPath -Confirm:$false
}
Context "Out-RsFolderContent with Proxy Parameter"{
@@ -78,7 +78,7 @@ Describe "Out-RsFolderContent" {
}
# Removing local folder content downloaded from report server used for testing
Remove-Item $destinationPath -Confirm:$false -Recurse
- Remove-RsCatalogItem -RsFolder $rsFolderPath
+ Remove-RsCatalogItem -RsFolder $rsFolderPath -Confirm:$false
}
Context "Out-RsFolderContent with Proxy and ReportServer Parameter"{
@@ -102,7 +102,7 @@ Describe "Out-RsFolderContent" {
}
# Removing local folder content downloaded from report server used for testing
Remove-Item $destinationPath -Confirm:$false -Recurse
- Remove-RsCatalogItem -RsFolder $rsFolderPath
+ Remove-RsCatalogItem -RsFolder $rsFolderPath -Confirm:$false
}
Context "Out-RsFolderContent with recurse parameters"{
@@ -143,7 +143,7 @@ Describe "Out-RsFolderContent" {
$localReport.Name | Should Be 'testResources2'
}
# Removing local folder content downloaded from report server used for testing
- Remove-RsCatalogItem -RsFolder $rsFolderPath
+ Remove-RsCatalogItem -RsFolder $rsFolderPath -Confirm:$false
Remove-Item $destinationPath -Confirm:$false -Recurse
}
}
\ No newline at end of file
diff --git a/Tests/CatalogItems/Remove-RsCatalogItem.Tests.ps1 b/Tests/CatalogItems/Remove-RsCatalogItem.Tests.ps1
index 57acae59..34e6769e 100644
--- a/Tests/CatalogItems/Remove-RsCatalogItem.Tests.ps1
+++ b/Tests/CatalogItems/Remove-RsCatalogItem.Tests.ps1
@@ -15,7 +15,7 @@ Describe "Remove-RsCatalogItem" {
$rsDataSourcesList.Count | Should Be 1
# Remove a DataSource
$rsDataSourcePath = $folderPath + '/SutWriteRsFolderContent_DataSource'
- Remove-RsCatalogItem -RsFolder $rsDataSourcePath
+ Remove-RsCatalogItem -RsFolder $rsDataSourcePath -Confirm:$false
$rsDataSourcesList = (Get-RsFolderContent -RsFolder $folderPath ) | Where-Object TypeName -eq 'DataSource'
$rsDataSourcesList.Count | Should Be 0
}
@@ -25,7 +25,7 @@ Describe "Remove-RsCatalogItem" {
$rsReportsList.Count | Should Be 1
# Remove a report
$rsReportPath = $folderPath + '/emptyReport'
- Remove-RsCatalogItem -RsFolder $rsReportPath
+ Remove-RsCatalogItem -RsFolder $rsReportPath -Confirm:$false
$rsReportsList = (Get-RsFolderContent -RsFolder $folderPath ) | Where-Object TypeName -eq 'Report'
$rsReportsList.Count | Should Be 0
}
@@ -35,7 +35,7 @@ Describe "Remove-RsCatalogItem" {
$rsDataSetsList.Count | Should Be 1
# Remove a report
$rsDataSetPath = $folderPath + '/UnDataset'
- Remove-RsCatalogItem -RsFolder $rsDataSetPath
+ Remove-RsCatalogItem -RsFolder $rsDataSetPath -Confirm:$false
$rsDataSetsList = (Get-RsFolderContent -RsFolder $folderPath ) | Where-Object TypeName -eq 'DataSet'
$rsDataSetsList.Count | Should Be 0
}
@@ -46,7 +46,7 @@ Describe "Remove-RsCatalogItem" {
$folderPath = '/' + $folderName
$folder.count | Should Be 1
# Remove a RsFolder
- Remove-RsCatalogItem -RsFolder $folderPath
+ Remove-RsCatalogItem -RsFolder $folderPath -Confirm:$false
$folderList = Get-RsFolderContent -RsFolder '/'
$folder = $folderList | Where-Object name -eq $folderName
$folder.count | Should Be 0
@@ -63,7 +63,7 @@ Describe "Remove-RsCatalogItem" {
$folder = $folderList | Where-Object name -eq $folderName
$folder.count | Should Be 1
# Remove a RsFolder
- Remove-RsCatalogItem -Path $folderPath -Proxy $proxy
+ Remove-RsCatalogItem -Path $folderPath -Proxy $proxy -Confirm:$false
$folderList = Get-RsFolderContent -RsFolder '/'
$folder = $folderList | Where-Object name -eq $folderName
$folder.count | Should Be 0
@@ -81,7 +81,7 @@ Describe "Remove-RsCatalogItem" {
$folder = $folderList | Where-Object name -eq $folderName
$folder.count | Should Be 1
# Remove a RsFolder
- Remove-RsCatalogItem -Path $folderPath -Proxy $proxy -ReportServerUri $reporServerUri
+ Remove-RsCatalogItem -Path $folderPath -Proxy $proxy -ReportServerUri $reporServerUri -Confirm:$false
$folderList = Get-RsFolderContent -RsFolder '/'
$folder = $folderList | Where-Object name -eq $folderName
$folder.count | Should Be 0
@@ -98,7 +98,7 @@ Describe "Remove-RsCatalogItem" {
$folder = $folderList | Where-Object name -eq $folderName
$folder.count | Should Be 1
# Remove a RsFolder
- Remove-RsCatalogItem -ReportServerUri $reportServerUri -Path $folderPath
+ Remove-RsCatalogItem -ReportServerUri $reportServerUri -Path $folderPath -Confirm:$false
$folderList = Get-RsFolderContent -RsFolder '/'
$folder = $folderList | Where-Object name -eq $folderName
$folder.count | Should Be 0
@@ -114,7 +114,7 @@ Describe "Remove-RsCatalogItem" {
$folder = $folderList | Where-Object name -eq $folderName
$folder.count | Should Be 1
# Remove a RsFolder
- $folder | Remove-RsCatalogItem
+ $folder | Remove-RsCatalogItem -Confirm:$false
$folderList = Get-RsFolderContent -RsFolder '/'
$folder = $folderList | Where-Object name -eq $folderName
$folder.count | Should Be 0
diff --git a/Tests/CatalogItems/Remove-RsSubscription.Tests.ps1 b/Tests/CatalogItems/Remove-RsSubscription.Tests.ps1
index 9fe18fe9..b9a8cd25 100644
--- a/Tests/CatalogItems/Remove-RsSubscription.Tests.ps1
+++ b/Tests/CatalogItems/Remove-RsSubscription.Tests.ps1
@@ -1,380 +1,150 @@
# Copyright (c) 2016 Microsoft Corporation. All Rights Reserved.
# Licensed under the MIT License (MIT)
-#Not in use right now - need email configuration on the report server
-Function Get-NewSubscription
+$reportServerUri = if ($env:PesterServerUrl -eq $null) { 'http://localhost/reportserver' } else { $env:PesterServerUrl }
+
+Function Set-FolderReportDataSource
{
+ param (
+ [string]
+ $NewFolderPath
+ )
+
+ $tempProxy = New-RsWebServiceProxy -ReportServerUri $reportServerUri
+
+ # uploading emptyReport.rdl
+ $localResourcesPath = (Get-Item -Path ".\").FullName + '\Tests\CatalogItems\testResources\emptyReport.rdl'
+ $null = Write-RsCatalogItem -Path $localResourcesPath -RsFolder $NewFolderPath -Proxy $tempProxy
+ $report = (Get-RsFolderContent -RsFolder $NewFolderPath -Proxy $tempProxy)| Where-Object TypeName -eq 'Report'
+
+ # uploading UnDataset.rsd
+ $localResourcesPath = (Get-Item -Path ".\").FullName + '\Tests\CatalogItems\testResources\UnDataset.rsd'
+ $null = Write-RsCatalogItem -Path $localResourcesPath -RsFolder $NewFolderPath -Proxy $tempProxy
+ $dataSet = (Get-RsFolderContent -RsFolder $NewFolderPath -Proxy $tempProxy) | Where-Object TypeName -eq 'DataSet'
+ $DataSetPath = $NewFolderPath + '/UnDataSet'
+
+ # creating a shared data source with Dummy credentials
+ $newRSDSName = "DataSource"
+ $newRSDSExtension = "SQL"
+ $newRSDSConnectionString = "Initial Catalog=DB; Data Source=Instance"
+ $newRSDSCredentialRetrieval = "Store"
+ $Pass = ConvertTo-SecureString -String "123" -AsPlainText -Force
+ $newRSDSCredential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList "sql", $Pass
+ $null = New-RsDataSource -RsFolder $NewFolderPath -Name $newRSDSName -Extension $newRSDSExtension -ConnectionString $newRSDSConnectionString -CredentialRetrieval $newRSDSCredentialRetrieval -DatasourceCredentials $newRSDSCredential -Proxy $tempProxy
+
+ $DataSourcePath = "$NewFolderPath/$newRSDSName"
+
+ # retrieving embedded dataset and datasources
+ $RsDataSet = Get-RsItemReference -Path $report.Path -Proxy $tempProxy | Where-Object ReferenceType -eq 'DataSet'
+ $RsDataSource = Get-RsItemReference -Path $report.Path -Proxy $tempProxy | Where-Object ReferenceType -eq 'DataSource'
+ $RsDataSetSource = Get-RsItemReference -Path $DataSetPath -Proxy $tempProxy | Where-Object ReferenceType -eq 'DataSource'
+
+ # Set data source and data set for all objects
+ $null = Set-RsDataSourceReference -Path $DataSetPath -DataSourceName $RsDataSetSource.Name -DataSourcePath $DataSourcePath -Proxy $tempProxy
+ $null = Set-RsDataSourceReference -Path $report.Path -DataSourceName $RsDataSource.Name -DataSourcePath $DataSourcePath -Proxy $tempProxy
+ $null = Set-RsDataSetReference -Path $report.Path -DataSetName $RsDataSet.Name -DataSetPath $dataSet.Path -Proxy $tempProxy
+
+ return $report
+}
+
+Describe "Remove-RsSubscription" {
+ $folderPath = ''
+ $report = $null
+
+ BeforeEach {
+ $folderName = 'SutGetRsItemReference_MinParameters' + [guid]::NewGuid()
+ New-RsFolder -Path / -FolderName $folderName -ReportServerUri $reportServerUri
+ $folderPath = '/' + $folderName
- [xml]$matchData = '2017-07-14T08:00:00.000+01:001truetruetruetruetrue'
-
- $proxy = New-RsWebServiceProxy
- $namespace = $proxy.GetType().NameSpace
-
- $ExtensionSettingsDataType = "$namespace.ExtensionSettings"
- $ParameterValueOrFieldReference = "$namespace.ParameterValueOrFieldReference[]"
- $ParameterValueDataType = "$namespace.ParameterValue"
-
- #Set ExtensionSettings
- $ExtensionSettings = New-Object $ExtensionSettingsDataType
-
- $ExtensionSettings.Extension = "Report Server Email"
-
- #Set ParameterValues
- $ParameterValues = New-Object $ParameterValueOrFieldReference -ArgumentList 8
-
- $to = New-Object $ParameterValueDataType
- $to.Name = "TO";
- $to.Value = "mail@rstools.com";
- $ParameterValues[0] = $to;
-
- $replyTo = New-Object $ParameterValueDataType
- $replyTo.Name = "ReplyTo";
- $replyTo.Value ="dank@rstools.com";
- $ParameterValues[1] = $replyTo;
-
- $includeReport = New-Object $ParameterValueDataType
- $includeReport.Name = "IncludeReport";
- $includeReport.Value = "False";
- $ParameterValues[2] = $includeReport;
-
- $renderFormat = New-Object $ParameterValueDataType
- $renderFormat.Name = "RenderFormat";
- $renderFormat.Value = "MHTML";
- $ParameterValues[3] = $renderFormat;
-
- $priority = New-Object $ParameterValueDataType
- $priority.Name = "Priority";
- $priority.Value = "NORMAL";
- $ParameterValues[4] = $priority;
-
- $subject = New-Object $ParameterValueDataType
- $subject.Name = "Subject";
- $subject.Value = "Your sales report";
- $ParameterValues[5] = $subject;
-
- $comment = New-Object $ParameterValueDataType
- $comment.Name = "Comment";
- $comment.Value = "Here is the link to your report.";
- $ParameterValues[6] = $comment;
-
- $includeLink = New-Object $ParameterValueDataType
- $includeLink.Name = "IncludeLink";
- $includeLink.Value = "True";
- $ParameterValues[7] = $includeLink;
-
- $ExtensionSettings.ParameterValues = $ParameterValues
-
- $subscription = [pscustomobject]@{
- DeliverySettings = $ExtensionSettings
- Description = "Send email to mail@rstools.com"
- EventType = "TimedSubscription"
- IsDataDriven = $false
- MatchData = $matchData.OuterXml
+ # upload test reports and initialize data sources/data sets
+ $report = Set-FolderReportDataSource($folderPath)
+
+ # create a test subscription
+ New-RsSubscription -ReportServerUri $reportServerUri -RsItem $report.Path -DeliveryMethod FileShare -Schedule (New-RsScheduleXml) -FileSharePath '\\unc\path' -Filename 'Report' -FileWriteMode Overwrite -RenderFormat PDF
}
-
- return $subscription
-}
-Function Get-NewFileShareSubscription
-{
+ AfterEach {
+ Remove-RsCatalogItem -RsFolder $folderPath -ReportServerUri $reportServerUri -Confirm:$false
+ }
+
+ Context "Remove-RsSubscription with Proxy parameter" {
+ It "Should remove a subscription" {
+ $rsProxy = New-RsWebServiceProxy -ReportServerUri $reportServerUri
+ $reportSubscriptions = Get-RsSubscription -Path $report.Path -Proxy $rsProxy
+ @($reportSubscriptions).Count | Should Be 1
+
+ Remove-RsSubscription -SubscriptionID $reportSubscriptions.SubscriptionID -Proxy $rsProxy -Confirm:$false
+
+ $reportSubscriptions = Get-RsSubscription -Path $report.Path -Proxy $rsProxy
+ @($reportSubscriptions).Count | Should Be 0
+ }
+
+ It "Should remove all subscriptions" {
+ $rsProxy = New-RsWebServiceProxy -ReportServerUri $reportServerUri
+
+ # creating an additional subscription
+ New-RsSubscription -Proxy $rsProxy -RsItem $report.Path -DeliveryMethod FileShare -Schedule (New-RsScheduleXml) -FileSharePath '\\unc\path' -Filename 'Report' -FileWriteMode Overwrite -RenderFormat PDF
+
+ $reportSubscriptions = Get-RsSubscription -Path $report.Path -Proxy $rsProxy
+ @($reportSubscriptions).Count | Should Be 2
+
+ Remove-RsSubscription -Subscription $reportSubscriptions -Proxy $rsProxy -Confirm:$false
- [xml]$matchData = '2017-07-14T08:00:00.000+01:001truetruetruetruetrue'
-
- $proxy = New-RsWebServiceProxy
- $namespace = $proxy.GetType().NameSpace
-
- $ExtensionSettingsDataType = "$namespace.ExtensionSettings"
- $ParameterValueOrFieldReference = "$namespace.ParameterValueOrFieldReference[]"
- $ParameterValueDataType = "$namespace.ParameterValue"
-
- #Set ExtensionSettings
- $ExtensionSettings = New-Object $ExtensionSettingsDataType
-
- $ExtensionSettings.Extension = "Report Server FileShare"
-
- #Set ParameterValues
- $ParameterValues = New-Object $ParameterValueOrFieldReference -ArgumentList 7
-
- $to = New-Object $ParameterValueDataType
- $to.Name = "PATH";
- $to.Value = "\\unc\path";
- $ParameterValues[0] = $to;
-
- $replyTo = New-Object $ParameterValueDataType
- $replyTo.Name = "FILENAME";
- $replyTo.Value ="Report";
- $ParameterValues[1] = $replyTo;
-
- $includeReport = New-Object $ParameterValueDataType
- $includeReport.Name = "FILEEXTN";
- $includeReport.Value = "True";
- $ParameterValues[2] = $includeReport;
-
- $renderFormat = New-Object $ParameterValueDataType
- $renderFormat.Name = "USERNAME";
- $renderFormat.Value = "user";
- $ParameterValues[3] = $renderFormat;
-
- $priority = New-Object $ParameterValueDataType
- $priority.Name = "RENDER_FORMAT";
- $priority.Value = "PDF";
- $ParameterValues[4] = $priority;
-
- $subject = New-Object $ParameterValueDataType
- $subject.Name = "WRITEMODE";
- $subject.Value = "Overwrite";
- $ParameterValues[5] = $subject;
-
- $comment = New-Object $ParameterValueDataType
- $comment.Name = "DEFAULTCREDENTIALS";
- $comment.Value = "False";
- $ParameterValues[6] = $comment;
-
- $ExtensionSettings.ParameterValues = $ParameterValues
-
- $subscription = [pscustomobject]@{
- DeliverySettings = $ExtensionSettings
- Description = "Shared on \\unc\path"
- EventType = "TimedSubscription"
- IsDataDriven = $false
- MatchData = $matchData.OuterXml
+ $reportSubscriptions = Get-RsSubscription -Path $report.Path -Proxy $rsProxy
+ @($reportSubscriptions).Count | Should Be 0
+ }
}
-
- return $subscription
-}
-Describe "Remove-RsSubscription" {
- Context "Remove-RsSubscription without parameters"{
- $folderName = 'SutGetRsItemReference_MinParameters' + [guid]::NewGuid()
- New-RsFolder -Path / -FolderName $folderName
- $folderPath = '/' + $folderName
- $localResourcesPath = (Get-Item -Path ".\").FullName + '\Tests\CatalogItems\testResources\emptyReport.rdl'
- Write-RsCatalogItem -Path $localResourcesPath -RsFolder $folderPath
- $report = (Get-RsFolderContent -RsFolder $folderPath )| Where-Object TypeName -eq 'Report'
- $subscription = Get-NewFileShareSubscription
-
- $localResourcesPath = (Get-Item -Path ".\").FullName + '\Tests\CatalogItems\testResources\UnDataset.rsd'
- Write-RsCatalogItem -Path $localResourcesPath -RsFolder $folderPath
- $dataSet = (Get-RsFolderContent -RsFolder $folderPath ) | Where-Object TypeName -eq 'DataSet'
- $DataSetPath = $folderPath + '/UnDataSet'
-
- $newRSDSName = "DataSource"
- $newRSDSExtension = "SQL"
- $newRSDSConnectionString = "Initial Catalog=DB; Data Source=Instance"
- $newRSDSCredentialRetrieval = "Store"
- #Dummy credentials
- $Pass = ConvertTo-SecureString -String "123" -AsPlainText -Force
- $newRSDSCredential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList "sql", $Pass
- New-RsDataSource -RsFolder $folderPath -Name $newRSDSName -Extension $newRSDSExtension -ConnectionString $newRSDSConnectionString -CredentialRetrieval $newRSDSCredentialRetrieval -DatasourceCredentials $newRSDSCredential
-
- $DataSourcePath = "$folderPath/$newRSDSName"
-
- $RsDataSet = Get-RsItemReference -Path $report.Path | Where-Object ReferenceType -eq 'DataSet'
- $RsDataSource = Get-RsItemReference -Path $report.Path | Where-Object ReferenceType -eq 'DataSource'
- $RsDataSetSource = Get-RsItemReference -Path $DataSetPath | Where-Object ReferenceType -eq 'DataSource'
-
- #Set data source and data set for all objects
- Set-RsDataSourceReference -Path $DataSetPath -DataSourceName $RsDataSetSource.Name -DataSourcePath $DataSourcePath
- Set-RsDataSourceReference -Path $report.Path -DataSourceName $RsDataSource.Name -DataSourcePath $DataSourcePath
- Set-RsDataSetReference -Path $report.Path -DataSetName $RsDataSet.Name -DataSetPath $dataSet.Path
-
-
- Set-RsSubscription -Subscription $subscription -Path $report.Path
-
- $reportSubscriptions = Get-RsSubscription -Path $report.Path
-
- It "Should set a subscription" {
- @($reportSubscriptions).Count | Should Be 1
- $reportSubscriptions.Report | Should Be "emptyReport"
- $reportSubscriptions.EventType | Should Be "TimedSubscription"
- $reportSubscriptions.IsDataDriven | Should Be $false
-
- }
-
- Remove-RsSubscription -SubscriptionID $reportSubscriptions.SubscriptionID
-
- $reportSubscriptions = Get-RsSubscription -Path $report.Path
-
- It "Subscription should not exist" {
- @($reportSubscriptions).Count | Should Be 0
- }
-
- Remove-RsCatalogItem -RsFolder $folderPath
+ Context "Remove-RsSubscription with ReportServerUri parameter" {
+ It "Should remove a subscription" {
+ $reportSubscriptions = Get-RsSubscription -Path $report.Path -ReportServerUri $reportServerUri
+ @($reportSubscriptions).Count | Should Be 1
+
+ Remove-RsSubscription -SubscriptionID $reportSubscriptions.SubscriptionID -ReportServerUri $reportServerUri -Confirm:$false
+
+ $reportSubscriptions = Get-RsSubscription -Path $report.Path -ReportServerUri $reportServerUri
+ @($reportSubscriptions).Count | Should Be 0
}
-
- Context "Remove-RsSubscription with Proxy parameter"{
- $folderName = 'SutGetRsItemReference_MinParameters' + [guid]::NewGuid()
- New-RsFolder -Path / -FolderName $folderName
- $folderPath = '/' + $folderName
- $localResourcesPath = (Get-Item -Path ".\").FullName + '\Tests\CatalogItems\testResources\emptyReport.rdl'
- Write-RsCatalogItem -Path $localResourcesPath -RsFolder $folderPath
- $report = (Get-RsFolderContent -RsFolder $folderPath )| Where-Object TypeName -eq 'Report'
- $subscription = Get-NewFileShareSubscription
-
- $localResourcesPath = (Get-Item -Path ".\").FullName + '\Tests\CatalogItems\testResources\UnDataset.rsd'
- Write-RsCatalogItem -Path $localResourcesPath -RsFolder $folderPath
- $dataSet = (Get-RsFolderContent -RsFolder $folderPath ) | Where-Object TypeName -eq 'DataSet'
- $DataSetPath = $folderPath + '/UnDataSet'
-
- $newRSDSName = "DataSource"
- $newRSDSExtension = "SQL"
- $newRSDSConnectionString = "Initial Catalog=DB; Data Source=Instance"
- $newRSDSCredentialRetrieval = "Store"
- #Dummy credentials
- $Pass = ConvertTo-SecureString -String "123" -AsPlainText -Force
- $newRSDSCredential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList "sql", $Pass
- New-RsDataSource -RsFolder $folderPath -Name $newRSDSName -Extension $newRSDSExtension -ConnectionString $newRSDSConnectionString -CredentialRetrieval $newRSDSCredentialRetrieval -DatasourceCredentials $newRSDSCredential
-
- $DataSourcePath = "$folderPath/$newRSDSName"
-
- $RsDataSet = Get-RsItemReference -Path $report.Path | Where-Object ReferenceType -eq 'DataSet'
- $RsDataSource = Get-RsItemReference -Path $report.Path | Where-Object ReferenceType -eq 'DataSource'
- $RsDataSetSource = Get-RsItemReference -Path $DataSetPath | Where-Object ReferenceType -eq 'DataSource'
-
- #Set data source and data set for all objects
- Set-RsDataSourceReference -Path $DataSetPath -DataSourceName $RsDataSetSource.Name -DataSourcePath $DataSourcePath
- Set-RsDataSourceReference -Path $report.Path -DataSourceName $RsDataSource.Name -DataSourcePath $DataSourcePath
- Set-RsDataSetReference -Path $report.Path -DataSetName $RsDataSet.Name -DataSetPath $dataSet.Path
-
- Set-RsSubscription -Subscription $subscription -Path $report.Path
-
- $reportSubscriptions = Get-RsSubscription -Path $report.Path
-
- It "Should set a subscription" {
- @($reportSubscriptions).Count | Should Be 1
- $reportSubscriptions.Report | Should Be "emptyReport"
- $reportSubscriptions.EventType | Should Be "TimedSubscription"
- $reportSubscriptions.IsDataDriven | Should Be $false
-
- }
-
- $proxy = New-RsWebServiceProxy
- Remove-RsSubscription -SubscriptionID $reportSubscriptions.SubscriptionID -Proxy $proxy
-
- $reportSubscriptions = Get-RsSubscription -Path $report.Path
-
- It "Subscription should not exist" {
- @($reportSubscriptions).Count | Should Be 0
- }
-
- Remove-RsCatalogItem -RsFolder $folderPath
+
+ It "Should remove all subscriptions" {
+ # creating an additional subscription
+ New-RsSubscription -ReportServerUri $reportServerUri -RsItem $report.Path -DeliveryMethod FileShare -Schedule (New-RsScheduleXml) -FileSharePath '\\unc\path' -Filename 'Report' -FileWriteMode Overwrite -RenderFormat PDF
+
+ $reportSubscriptions = Get-RsSubscription -Path $report.Path -ReportServerUri $reportServerUri
+ @($reportSubscriptions).Count | Should Be 2
+
+ Remove-RsSubscription -Subscription $reportSubscriptions -ReportServerUri $reportServerUri -Confirm:$false
+
+ $reportSubscriptions = Get-RsSubscription -Path $report.Path -ReportServerUri $reportServerUri
+ @($reportSubscriptions).Count | Should Be 0
}
+ }
+
+ Context "Remove-RsSubscription with ReportServerUri and Proxy Parameter" {
+ It "Should remove a subscription" {
+ $rsProxy = New-RsWebServiceProxy -ReportServerUri $reportServerUri
+ $reportSubscriptions = Get-RsSubscription -Path $report.Path -ReportServerUri $reportServerUri -Proxy $rsProxy
+ @($reportSubscriptions).Count | Should Be 1
- Context "Remove-RsSubscription with ReportServerUri Parameter"{
- $reportServerUri = 'http://localhost/reportserver'
-
- $folderName = 'SutGetRsItemReference_MinParameters' + [guid]::NewGuid()
- New-RsFolder -ReportServerUri $ReportServerUri -Path / -FolderName $folderName
- $folderPath = '/' + $folderName
- $localResourcesPath = (Get-Item -Path ".\").FullName + '\Tests\CatalogItems\testResources\emptyReport.rdl'
- Write-RsCatalogItem -ReportServerUri $ReportServerUri -Path $localResourcesPath -RsFolder $folderPath
- $report = (Get-RsFolderContent -ReportServerUri $ReportServerUri -RsFolder $folderPath )| Where-Object TypeName -eq 'Report'
- $subscription = Get-NewFileShareSubscription
-
- $localResourcesPath = (Get-Item -Path ".\").FullName + '\Tests\CatalogItems\testResources\UnDataset.rsd'
- Write-RsCatalogItem -ReportServerUri $ReportServerUri -Path $localResourcesPath -RsFolder $folderPath
- $dataSet = (Get-RsFolderContent -ReportServerUri $ReportServerUri -RsFolder $folderPath ) | Where-Object TypeName -eq 'DataSet'
- $DataSetPath = $folderPath + '/UnDataSet'
-
- $newRSDSName = "DataSource"
- $newRSDSExtension = "SQL"
- $newRSDSConnectionString = "Initial Catalog=DB; Data Source=Instance"
- $newRSDSCredentialRetrieval = "Store"
- #Dummy credentials
- $Pass = ConvertTo-SecureString -String "123" -AsPlainText -Force
- $newRSDSCredential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList "sql", $Pass
- New-RsDataSource -ReportServerUri $reportServerUri -RsFolder $folderPath -Name $newRSDSName -Extension $newRSDSExtension -ConnectionString $newRSDSConnectionString -CredentialRetrieval $newRSDSCredentialRetrieval -DatasourceCredentials $newRSDSCredential
-
- $DataSourcePath = "$folderPath/$newRSDSName"
-
- $RsDataSet = Get-RsItemReference -ReportServerUri $reportServerUri -Path $report.Path | Where-Object ReferenceType -eq 'DataSet'
- $RsDataSource = Get-RsItemReference -ReportServerUri $reportServerUri -Path $report.Path | Where-Object ReferenceType -eq 'DataSource'
- $RsDataSetSource = Get-RsItemReference -ReportServerUri $reportServerUri -Path $DataSetPath | Where-Object ReferenceType -eq 'DataSource'
-
- #Set data source and data set for all objects
- Set-RsDataSourceReference -ReportServerUri $reportServerUri -Path $DataSetPath -DataSourceName $RsDataSetSource.Name -DataSourcePath $DataSourcePath
- Set-RsDataSourceReference -ReportServerUri $reportServerUri -Path $report.Path -DataSourceName $RsDataSource.Name -DataSourcePath $DataSourcePath
- Set-RsDataSetReference -ReportServerUri $reportServerUri -Path $report.Path -DataSetName $RsDataSet.Name -DataSetPath $dataSet.Path
-
-
- Set-RsSubscription -Subscription $subscription -Path $report.Path -ReportServerUri $reportServerUri
-
- $reportSubscriptions = Get-RsSubscription -ReportServerUri $ReportServerUri -Path $report.Path
-
- It "Should exist a subscription" {
- @($reportSubscriptions).Count | Should Be 1
- $reportSubscriptions.Report | Should Be "emptyReport"
- $reportSubscriptions.EventType | Should Be "TimedSubscription"
- $reportSubscriptions.IsDataDriven | Should Be $false
-
- }
- Remove-RsSubscription -ReportServerUri $ReportServerUri -SubscriptionID $reportSubscriptions.SubscriptionID
-
- $reportSubscriptions = Get-RsSubscription -ReportServerUri $ReportServerUri -Path $report.Path
-
- It "Subscription should not exist" {
- @($reportSubscriptions).Count | Should Be 0
- }
- Remove-RsCatalogItem -ReportServerUri $ReportServerUri -RsFolder $folderPath
+ Remove-RsSubscription -SubscriptionID $reportSubscriptions.SubscriptionID -ReportServerUri $reportServerUri -Proxy $rsProxy -Confirm:$false
+
+ $reportSubscriptions = Get-RsSubscription -Path $report.Path -ReportServerUri $reportServerUri -Proxy $rsProxy
+ @($reportSubscriptions).Count | Should Be 0
}
- Context "Remove-RsSubscription with ReportServerUri and Proxy Parameter"{
- $reportServerUri = 'http://localhost/reportserver'
-
- $folderName = 'SutGetRsItemReference_MinParameters' + [guid]::NewGuid()
- New-RsFolder -Path / -FolderName $folderName
- $folderPath = '/' + $folderName
- $localResourcesPath = (Get-Item -Path ".\").FullName + '\Tests\CatalogItems\testResources\emptyReport.rdl'
- Write-RsCatalogItem -Path $localResourcesPath -RsFolder $folderPath
- $report = (Get-RsFolderContent -RsFolder $folderPath )| Where-Object TypeName -eq 'Report'
- $subscription = Get-NewFileShareSubscription
-
- $localResourcesPath = (Get-Item -Path ".\").FullName + '\Tests\CatalogItems\testResources\UnDataset.rsd'
- Write-RsCatalogItem -Path $localResourcesPath -RsFolder $folderPath
- $dataSet = (Get-RsFolderContent -RsFolder $folderPath ) | Where-Object TypeName -eq 'DataSet'
- $DataSetPath = $folderPath + '/UnDataSet'
-
- $newRSDSName = "DataSource"
- $newRSDSExtension = "SQL"
- $newRSDSConnectionString = "Initial Catalog=DB; Data Source=Instance"
- $newRSDSCredentialRetrieval = "Store"
- #Dummy credentials
- $Pass = ConvertTo-SecureString -String "123" -AsPlainText -Force
- $newRSDSCredential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList "sql", $Pass
- New-RsDataSource -RsFolder $folderPath -Name $newRSDSName -Extension $newRSDSExtension -ConnectionString $newRSDSConnectionString -CredentialRetrieval $newRSDSCredentialRetrieval -DatasourceCredentials $newRSDSCredential
-
- $DataSourcePath = "$folderPath/$newRSDSName"
-
- $RsDataSet = Get-RsItemReference -Path $report.Path | Where-Object ReferenceType -eq 'DataSet'
- $RsDataSource = Get-RsItemReference -Path $report.Path | Where-Object ReferenceType -eq 'DataSource'
- $RsDataSetSource = Get-RsItemReference -Path $DataSetPath | Where-Object ReferenceType -eq 'DataSource'
-
- #Set data source and data set for all objects
- Set-RsDataSourceReference -Path $DataSetPath -DataSourceName $RsDataSetSource.Name -DataSourcePath $DataSourcePath
- Set-RsDataSourceReference -Path $report.Path -DataSourceName $RsDataSource.Name -DataSourcePath $DataSourcePath
- Set-RsDataSetReference -Path $report.Path -DataSetName $RsDataSet.Name -DataSetPath $dataSet.Path
-
- Set-RsSubscription -Subscription $subscription -Path $report.Path
-
-
- $reportSubscriptions = Get-RsSubscription -Path $report.Path
-
- It "Should set a subscription" {
- @($reportSubscriptions).Count | Should Be 1
- $reportSubscriptions.Report | Should Be "emptyReport"
- $reportSubscriptions.EventType | Should Be "TimedSubscription"
- $reportSubscriptions.IsDataDriven | Should Be $false
-
- }
-
- $proxy = New-RsWebServiceProxy
- Remove-RsSubscription -SubscriptionID $reportSubscriptions.SubscriptionID -ReportServerUri $reportServerUri -Proxy $proxy
-
- $reportSubscriptions = Get-RsSubscription -Path $report.Path
-
- It "Subscription should not exist" {
- @($reportSubscriptions).Count | Should Be 0
- }
- Remove-RsCatalogItem -RsFolder $folderPath
+ It "Should remove all subscriptions" {
+ $rsProxy = New-RsWebServiceProxy -ReportServerUri $reportServerUri
+
+ # creating an additional subscription
+ New-RsSubscription -ReportServerUri $reportServerUri -Proxy $rsProxy -RsItem $report.Path -DeliveryMethod FileShare -Schedule (New-RsScheduleXml) -FileSharePath '\\unc\path' -Filename 'Report' -FileWriteMode Overwrite -RenderFormat PDF
+
+ $reportSubscriptions = Get-RsSubscription -Path $report.Path -ReportServerUri $reportServerUri -Proxy $rsProxy
+ @($reportSubscriptions).Count | Should Be 2
+
+ Remove-RsSubscription -Subscription $reportSubscriptions -ReportServerUri $reportServerUri -Proxy $rsProxy -Confirm:$false
+
+ $reportSubscriptions = Get-RsSubscription -Path $report.Path -ReportServerUri $reportServerUri -Proxy $rsProxy
+ @($reportSubscriptions).Count | Should Be 0
}
+ }
}
\ No newline at end of file
diff --git a/Tests/CatalogItems/Rest/New-RsRestFolder.Tests.ps1 b/Tests/CatalogItems/Rest/New-RsRestFolder.Tests.ps1
index 0500fe6a..b9de975f 100644
--- a/Tests/CatalogItems/Rest/New-RsRestFolder.Tests.ps1
+++ b/Tests/CatalogItems/Rest/New-RsRestFolder.Tests.ps1
@@ -33,7 +33,7 @@ Describe "New-RsRestFolder" {
$folderName = "SUT_NewRsRestFolder_" + [Guid]::NewGuid()
New-RsRestFolder -ReportPortalUri $reportPortalUri -FolderName $folderName -RsFolder / -Verbose
VerifyCatalogItemExists -itemType "Folder" -itemName $folderName -folderPath "/" -reportServerUri $reportServerUri
- Remove-RsCatalogItem -ReportServerUri $reportServerUri -RsFolder "/$folderName"
+ Remove-RsCatalogItem -ReportServerUri $reportServerUri -RsFolder "/$folderName" -Confirm:$false
}
}
@@ -44,7 +44,7 @@ Describe "New-RsRestFolder" {
$folderName = "SUT_NewRsRestFolder_" + [Guid]::NewGuid()
New-RsRestFolder -WebSession $webSession -FolderName $folderName -RsFolder / -Verbose
VerifyCatalogItemExists -itemType "Folder" -itemName $folderName -folderPath "/" -reportServerUri $reportServerUri
- Remove-RsCatalogItem -ReportServerUri $reportServerUri -RsFolder "/$folderName"
+ Remove-RsCatalogItem -ReportServerUri $reportServerUri -RsFolder "/$folderName" -Confirm:$false
}
}
}
\ No newline at end of file
diff --git a/Tests/CatalogItems/Rest/Out-RsRestCatalogItem.Tests.ps1 b/Tests/CatalogItems/Rest/Out-RsRestCatalogItem.Tests.ps1
index 99018e13..8588ec16 100644
--- a/Tests/CatalogItems/Rest/Out-RsRestCatalogItem.Tests.ps1
+++ b/Tests/CatalogItems/Rest/Out-RsRestCatalogItem.Tests.ps1
@@ -43,7 +43,7 @@ Describe "Out-RsRestCatalogItem" {
}
AfterEach {
- Remove-RsCatalogItem -ReportServerUri $reportServerUri -RsFolder $rsFolderPath
+ Remove-RsCatalogItem -ReportServerUri $reportServerUri -RsFolder $rsFolderPath -Confirm:$false
Remove-Item -Path $localFolderPath -Recurse
}
diff --git a/Tests/CatalogItems/Rest/Out-RsRestFolderContent.Tests.ps1 b/Tests/CatalogItems/Rest/Out-RsRestFolderContent.Tests.ps1
index e8da209c..eda9d74a 100644
--- a/Tests/CatalogItems/Rest/Out-RsRestFolderContent.Tests.ps1
+++ b/Tests/CatalogItems/Rest/Out-RsRestFolderContent.Tests.ps1
@@ -44,7 +44,7 @@ Describe "Out-RsRestFolderContent" {
}
AfterEach {
- Remove-RsCatalogItem -ReportServerUri $reportServerUri -RsFolder $rsFolderPath
+ Remove-RsCatalogItem -ReportServerUri $reportServerUri -RsFolder $rsFolderPath -Confirm:$false
if ($destinationPath -ne $null -and $destinationPath.Length -ne 0 -and (Test-Path $destinationPath))
{
Remove-Item -Path $destinationPath -Recurse
diff --git a/Tests/CatalogItems/Rest/Remove-RsRestCatalogItem.Tests.ps1 b/Tests/CatalogItems/Rest/Remove-RsRestCatalogItem.Tests.ps1
index a06cbe2e..f7ae8d7f 100644
--- a/Tests/CatalogItems/Rest/Remove-RsRestCatalogItem.Tests.ps1
+++ b/Tests/CatalogItems/Rest/Remove-RsRestCatalogItem.Tests.ps1
@@ -46,7 +46,7 @@ Describe "Remove-RsRestCatalogItem" {
AfterAll {
foreach ($path in $rsFolderPaths)
{
- Remove-RsCatalogItem -ReportServerUri $reportServerUri -RsFolder $path
+ Remove-RsCatalogItem -ReportServerUri $reportServerUri -RsFolder $path -Confirm:$false
}
}
diff --git a/Tests/CatalogItems/Rest/Write-RsRestCatalogItem.Tests.ps1 b/Tests/CatalogItems/Rest/Write-RsRestCatalogItem.Tests.ps1
index 96f39457..b190a8e5 100644
--- a/Tests/CatalogItems/Rest/Write-RsRestCatalogItem.Tests.ps1
+++ b/Tests/CatalogItems/Rest/Write-RsRestCatalogItem.Tests.ps1
@@ -38,7 +38,7 @@ Describe "Write-RsRestCatalogItem" {
}
AfterEach {
- Remove-RsCatalogItem -ReportServerUri $reportServerUri -RsFolder $rsFolderPath
+ Remove-RsCatalogItem -ReportServerUri $reportServerUri -RsFolder $rsFolderPath -Confirm:$false
}
Context "ReportPortalUri parameter" {
diff --git a/Tests/CatalogItems/Rest/Write-RsRestFolderContent.Tests.ps1 b/Tests/CatalogItems/Rest/Write-RsRestFolderContent.Tests.ps1
index 7421b2bb..8a34b170 100644
--- a/Tests/CatalogItems/Rest/Write-RsRestFolderContent.Tests.ps1
+++ b/Tests/CatalogItems/Rest/Write-RsRestFolderContent.Tests.ps1
@@ -38,7 +38,7 @@ Describe "Write-RsRestFolderContent" {
}
AfterEach {
- Remove-RsCatalogItem -ReportServerUri $reportServerUri -RsFolder $rsFolderPath
+ Remove-RsCatalogItem -ReportServerUri $reportServerUri -RsFolder $rsFolderPath -Confirm:$false
}
Context "ReportPortalUri parameter" {
diff --git a/Tests/CatalogItems/Set-RsDataSetReference.Tests.ps1 b/Tests/CatalogItems/Set-RsDataSetReference.Tests.ps1
index 10bbacde..ac807d88 100644
--- a/Tests/CatalogItems/Set-RsDataSetReference.Tests.ps1
+++ b/Tests/CatalogItems/Set-RsDataSetReference.Tests.ps1
@@ -21,7 +21,7 @@ Describe "Set-RsDatsSetReference" {
$reportDataSetReferencePath | Should Not Be $newReportDataSetReferencePath
$newReportDataSetReferencePath | Should Be $dataSet.Path
}
- Remove-RsCatalogItem -RsFolder $folderPath
+ Remove-RsCatalogItem -RsFolder $folderPath -Confirm:$false
}
Context "Set-RsDatsSetReference with Proxy Parameter"{
@@ -43,7 +43,7 @@ Describe "Set-RsDatsSetReference" {
$reportDataSetReferencePath | Should Not Be $newReportDataSetReferencePath
$newReportDataSetReferencePath | Should Be $dataSet.Path
}
- Remove-RsCatalogItem -RsFolder $folderPath
+ Remove-RsCatalogItem -RsFolder $folderPath -Confirm:$false
}
Context "Set-RsDatsSetReference with Report Server Parameter"{
@@ -65,7 +65,7 @@ Describe "Set-RsDatsSetReference" {
$reportDataSetReferencePath | Should Not Be $newReportDataSetReferencePath
$newReportDataSetReferencePath | Should Be $dataSet.Path
}
- Remove-RsCatalogItem -RsFolder $folderPath
+ Remove-RsCatalogItem -RsFolder $folderPath -Confirm:$false
}
Context "Set-RsDatsSetReference with ReportServerUri and Proxy parameters"{
@@ -88,7 +88,7 @@ Describe "Set-RsDatsSetReference" {
$reportDataSetReferencePath | Should Not Be $newReportDataSetReferencePath
$newReportDataSetReferencePath | Should Be $dataSet.Path
}
- Remove-RsCatalogItem -RsFolder $folderPath
+ Remove-RsCatalogItem -RsFolder $folderPath -Confirm:$false
}
}
diff --git a/Tests/CatalogItems/Set-RsDataSource.Tests.ps1 b/Tests/CatalogItems/Set-RsDataSource.Tests.ps1
index c99540a4..40f685ad 100644
--- a/Tests/CatalogItems/Set-RsDataSource.Tests.ps1
+++ b/Tests/CatalogItems/Set-RsDataSource.Tests.ps1
@@ -23,7 +23,7 @@ Describe "Set-RsDataSource" {
}
AfterEach {
- Remove-RsCatalogItem -RsFolder $dataSourcePath
+ Remove-RsCatalogItem -RsFolder $dataSourcePath -Confirm:$false
}
It "Should set a RsDataSource with min parameters" {
diff --git a/Tests/CatalogItems/Set-RsItemDataSource.Tests.ps1 b/Tests/CatalogItems/Set-RsItemDataSource.Tests.ps1
index 78c6c024..17404158 100644
--- a/Tests/CatalogItems/Set-RsItemDataSource.Tests.ps1
+++ b/Tests/CatalogItems/Set-RsItemDataSource.Tests.ps1
@@ -21,8 +21,8 @@ Describe "Set-RsItemDataSource" {
}
AfterEach {
- Remove-RsCatalogItem -ReportServerUri $reportServerUri -RsItem $datasourcesReportPath
- Remove-RsCatalogItem -ReportServerUri $reportServerUri -RsItem $rsFolderPath
+ Remove-RsCatalogItem -ReportServerUri $reportServerUri -RsItem $datasourcesReportPath -Confirm:$false
+ Remove-RsCatalogItem -ReportServerUri $reportServerUri -RsItem $rsFolderPath -Confirm:$false
}
Context "Updates data sources with Proxy parameter" {
diff --git a/Tests/CatalogItems/Set-RsSubscription.Tests.ps1 b/Tests/CatalogItems/Set-RsSubscription.Tests.ps1
index 843cbddc..7ef8887e 100644
--- a/Tests/CatalogItems/Set-RsSubscription.Tests.ps1
+++ b/Tests/CatalogItems/Set-RsSubscription.Tests.ps1
@@ -1,149 +1,7 @@
# Copyright (c) 2016 Microsoft Corporation. All Rights Reserved.
# Licensed under the MIT License (MIT)
-#Not in use right now - need email configuration on the report server
-Function Get-NewSubscription
-{
-
- [xml]$matchData = '2017-07-14T08:00:00.000+01:001truetruetruetruetrue'
-
- $proxy = New-RsWebServiceProxy
- $namespace = $proxy.GetType().NameSpace
-
- $ExtensionSettingsDataType = "$namespace.ExtensionSettings"
- $ParameterValueOrFieldReference = "$namespace.ParameterValueOrFieldReference[]"
- $ParameterValueDataType = "$namespace.ParameterValue"
-
- #Set ExtensionSettings
- $ExtensionSettings = New-Object $ExtensionSettingsDataType
-
- $ExtensionSettings.Extension = "Report Server Email"
-
- #Set ParameterValues
- $ParameterValues = New-Object $ParameterValueOrFieldReference -ArgumentList 8
-
- $to = New-Object $ParameterValueDataType
- $to.Name = "TO";
- $to.Value = "mail@rstools.com";
- $ParameterValues[0] = $to;
-
- $replyTo = New-Object $ParameterValueDataType
- $replyTo.Name = "ReplyTo";
- $replyTo.Value ="dank@rstools.com";
- $ParameterValues[1] = $replyTo;
-
- $includeReport = New-Object $ParameterValueDataType
- $includeReport.Name = "IncludeReport";
- $includeReport.Value = "False";
- $ParameterValues[2] = $includeReport;
-
- $renderFormat = New-Object $ParameterValueDataType
- $renderFormat.Name = "RenderFormat";
- $renderFormat.Value = "MHTML";
- $ParameterValues[3] = $renderFormat;
-
- $priority = New-Object $ParameterValueDataType
- $priority.Name = "Priority";
- $priority.Value = "NORMAL";
- $ParameterValues[4] = $priority;
-
- $subject = New-Object $ParameterValueDataType
- $subject.Name = "Subject";
- $subject.Value = "Your sales report";
- $ParameterValues[5] = $subject;
-
- $comment = New-Object $ParameterValueDataType
- $comment.Name = "Comment";
- $comment.Value = "Here is the link to your report.";
- $ParameterValues[6] = $comment;
-
- $includeLink = New-Object $ParameterValueDataType
- $includeLink.Name = "IncludeLink";
- $includeLink.Value = "True";
- $ParameterValues[7] = $includeLink;
-
- $ExtensionSettings.ParameterValues = $ParameterValues
-
- $subscription = [pscustomobject]@{
- DeliverySettings = $ExtensionSettings
- Description = "Send email to mail@rstools.com"
- EventType = "TimedSubscription"
- IsDataDriven = $false
- MatchData = $matchData.OuterXml
- Values = $null
- }
-
- return $subscription
-}
-
-Function Get-NewFileShareSubscription
-{
-
- [xml]$matchData = '2017-07-14T08:00:00.000+01:001truetruetruetruetrue'
-
- $proxy = New-RsWebServiceProxy
- $namespace = $proxy.GetType().NameSpace
-
- $ExtensionSettingsDataType = "$namespace.ExtensionSettings"
- $ParameterValueOrFieldReference = "$namespace.ParameterValueOrFieldReference[]"
- $ParameterValueDataType = "$namespace.ParameterValue"
-
- #Set ExtensionSettings
- $ExtensionSettings = New-Object $ExtensionSettingsDataType
-
- $ExtensionSettings.Extension = "Report Server FileShare"
-
- #Set ParameterValues
- $ParameterValues = New-Object $ParameterValueOrFieldReference -ArgumentList 7
-
- $to = New-Object $ParameterValueDataType
- $to.Name = "PATH";
- $to.Value = "\\unc\path";
- $ParameterValues[0] = $to;
-
- $replyTo = New-Object $ParameterValueDataType
- $replyTo.Name = "FILENAME";
- $replyTo.Value ="Report";
- $ParameterValues[1] = $replyTo;
-
- $includeReport = New-Object $ParameterValueDataType
- $includeReport.Name = "FILEEXTN";
- $includeReport.Value = "True";
- $ParameterValues[2] = $includeReport;
-
- $renderFormat = New-Object $ParameterValueDataType
- $renderFormat.Name = "USERNAME";
- $renderFormat.Value = "user";
- $ParameterValues[3] = $renderFormat;
-
- $priority = New-Object $ParameterValueDataType
- $priority.Name = "RENDER_FORMAT";
- $priority.Value = "PDF";
- $ParameterValues[4] = $priority;
-
- $subject = New-Object $ParameterValueDataType
- $subject.Name = "WRITEMODE";
- $subject.Value = "Overwrite";
- $ParameterValues[5] = $subject;
-
- $comment = New-Object $ParameterValueDataType
- $comment.Name = "DEFAULTCREDENTIALS";
- $comment.Value = "False";
- $ParameterValues[6] = $comment;
-
- $ExtensionSettings.ParameterValues = $ParameterValues
-
- $subscription = [pscustomobject]@{
- DeliverySettings = $ExtensionSettings
- Description = "Shared on \\unc\path"
- EventType = "TimedSubscription"
- IsDataDriven = $false
- MatchData = $matchData.OuterXml
- Values = $null
- }
-
- return $subscription
-}
+$reportServerUri = if ($env:PesterServerUrl -eq $null) { 'http://localhost/reportserver' } else { $env:PesterServerUrl }
Function Set-FolderReportDataSource
{
@@ -151,277 +9,192 @@ Function Set-FolderReportDataSource
[string]
$NewFolderPath
)
-
-
- $localResourcesPath = (Get-Item -Path ".\").FullName + '\Tests\CatalogItems\testResources\emptyReport.rdl'
- $null = Write-RsCatalogItem -Path $localResourcesPath -RsFolder $NewFolderPath
- $report = (Get-RsFolderContent -RsFolder $NewFolderPath )| Where-Object TypeName -eq 'Report'
+ $tempProxy = New-RsWebServiceProxy -ReportServerUri $reportServerUri
+
+ # uploading emptyReport.rdl
+ $localResourcesPath = (Get-Item -Path ".\").FullName + '\Tests\CatalogItems\testResources\emptyReport.rdl'
+ $null = Write-RsCatalogItem -Path $localResourcesPath -RsFolder $NewFolderPath -Proxy $tempProxy
+ $report = (Get-RsFolderContent -RsFolder $NewFolderPath -Proxy $tempProxy)| Where-Object TypeName -eq 'Report'
+
+ # uploading UnDataset.rsd
$localResourcesPath = (Get-Item -Path ".\").FullName + '\Tests\CatalogItems\testResources\UnDataset.rsd'
- $null = Write-RsCatalogItem -Path $localResourcesPath -RsFolder $NewFolderPath
- $dataSet = (Get-RsFolderContent -RsFolder $NewFolderPath ) | Where-Object TypeName -eq 'DataSet'
+ $null = Write-RsCatalogItem -Path $localResourcesPath -RsFolder $NewFolderPath -Proxy $tempProxy
+ $dataSet = (Get-RsFolderContent -RsFolder $NewFolderPath -Proxy $tempProxy) | Where-Object TypeName -eq 'DataSet'
$DataSetPath = $NewFolderPath + '/UnDataSet'
-
+
+ # creating a shared data source with Dummy credentials
$newRSDSName = "DataSource"
$newRSDSExtension = "SQL"
$newRSDSConnectionString = "Initial Catalog=DB; Data Source=Instance"
$newRSDSCredentialRetrieval = "Store"
- #Dummy credentials
$Pass = ConvertTo-SecureString -String "123" -AsPlainText -Force
$newRSDSCredential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList "sql", $Pass
- $null = New-RsDataSource -RsFolder $NewFolderPath -Name $newRSDSName -Extension $newRSDSExtension -ConnectionString $newRSDSConnectionString -CredentialRetrieval $newRSDSCredentialRetrieval -DatasourceCredentials $newRSDSCredential
+ $null = New-RsDataSource -RsFolder $NewFolderPath -Name $newRSDSName -Extension $newRSDSExtension -ConnectionString $newRSDSConnectionString -CredentialRetrieval $newRSDSCredentialRetrieval -DatasourceCredentials $newRSDSCredential -Proxy $tempProxy
$DataSourcePath = "$NewFolderPath/$newRSDSName"
- $RsDataSet = Get-RsItemReference -Path $report.Path | Where-Object ReferenceType -eq 'DataSet'
- $RsDataSource = Get-RsItemReference -Path $report.Path | Where-Object ReferenceType -eq 'DataSource'
- $RsDataSetSource = Get-RsItemReference -Path $DataSetPath | Where-Object ReferenceType -eq 'DataSource'
+ # retrieving embedded dataset and datasources
+ $RsDataSet = Get-RsItemReference -Path $report.Path -Proxy $tempProxy | Where-Object ReferenceType -eq 'DataSet'
+ $RsDataSource = Get-RsItemReference -Path $report.Path -Proxy $tempProxy | Where-Object ReferenceType -eq 'DataSource'
+ $RsDataSetSource = Get-RsItemReference -Path $DataSetPath -Proxy $tempProxy | Where-Object ReferenceType -eq 'DataSource'
- #Set data source and data set for all objects
- $null = Set-RsDataSourceReference -Path $DataSetPath -DataSourceName $RsDataSetSource.Name -DataSourcePath $DataSourcePath
- $null = Set-RsDataSourceReference -Path $report.Path -DataSourceName $RsDataSource.Name -DataSourcePath $DataSourcePath
- $null = Set-RsDataSetReference -Path $report.Path -DataSetName $RsDataSet.Name -DataSetPath $dataSet.Path
+ # Set data source and data set for all objects
+ $null = Set-RsDataSourceReference -Path $DataSetPath -DataSourceName $RsDataSetSource.Name -DataSourcePath $DataSourcePath -Proxy $tempProxy
+ $null = Set-RsDataSourceReference -Path $report.Path -DataSourceName $RsDataSource.Name -DataSourcePath $DataSourcePath -Proxy $tempProxy
+ $null = Set-RsDataSetReference -Path $report.Path -DataSetName $RsDataSet.Name -DataSetPath $dataSet.Path -Proxy $tempProxy
return $report
}
-Describe "Set-RsSubscription" {
- Context "Set-RsSubscription without parameters"{
- $folderName = 'SutGetRsItemReference_MinParameters' + [guid]::NewGuid()
- $null = New-RsFolder -Path / -FolderName $folderName
- $folderPath = '/' + $folderName
+Describe "Update-RsSubscription" {
+ $folderPath = ''
+ $newReport = $null
- $newReport = Set-FolderReportDataSource($folderPath)
+ BeforeEach {
+ $folderName = 'SutGetRsItemReference_MinParameters' + [guid]::NewGuid()
+ New-RsFolder -Path / -FolderName $folderName -ReportServerUri $reportServerUri
+ $folderPath = '/' + $folderName
- $subscription = Get-NewFileShareSubscription
+ # upload test reports and initialize data sources/data sets
+ $newReport = Set-FolderReportDataSource($folderPath)
- Set-RsSubscription -Subscription $subscription -Path $newReport.Path
-
- $reportSubscriptions = Get-RsSubscription -Path $newReport.Path
+ # create a test subscription
+ New-RsSubscription -ReportServerUri $reportServerUri -RsItem $newReport.Path -DeliveryMethod FileShare -Schedule (New-RsScheduleXml) -FileSharePath '\\unc\path' -Filename 'Report' -FileWriteMode Overwrite -RenderFormat PDF
+ }
- It "Should set a subscription" {
- @($reportSubscriptions).Count | Should Be 1
- $reportSubscriptions.Report | Should Be "emptyReport"
- $reportSubscriptions.EventType | Should Be "TimedSubscription"
- $reportSubscriptions.IsDataDriven | Should Be $false
- }
- Remove-RsCatalogItem -RsFolder $folderPath
- }
-
- Context "Set-RsSubscription with Proxy parameter"{
- $folderName = 'SutGetRsItemReference_MinParameters' + [guid]::NewGuid()
- $null = New-RsFolder -Path / -FolderName $folderName
- $folderPath = '/' + $folderName
-
- $proxy = New-RsWebServiceProxy
-
- $newReport = Set-FolderReportDataSource($folderPath)
-
- $subscription = Get-NewFileShareSubscription
-
- Set-RsSubscription -Subscription $subscription -Path $newReport.Path -Proxy $proxy
-
- $reportSubscriptions = Get-RsSubscription -Path $newReport.Path
-
- It "Should set a subscription" {
- @($reportSubscriptions).Count | Should Be 1
- $reportSubscriptions.Report | Should Be "emptyReport"
- $reportSubscriptions.EventType | Should Be "TimedSubscription"
- $reportSubscriptions.IsDataDriven | Should Be $false
- }
- Remove-RsCatalogItem -RsFolder $folderPath
+ AfterEach {
+ Remove-RsCatalogItem -RsFolder $folderPath -ReportServerUri $reportServerUri -Confirm:$false
+ }
+
+ Context "Set-RsSubscription with Proxy parameter" {
+ BeforeEach {
+ Grant-RsSystemRole -Identity 'LOCAL' -RoleName 'System User' -ReportServerUri $reportServerUri
+ Grant-RsCatalogItemRole -Identity 'LOCAL' -RoleName 'Browser' -Path $newReport.path -ReportServerUri $reportServerUri
}
- Context "Set-RsSubscription with ReportServerUri Parameter"{
- $folderName = 'SutGetRsItemReference_MinParameters' + [guid]::NewGuid()
- $null = New-RsFolder -Path / -FolderName $folderName
- $folderPath = '/' + $folderName
-
- $reportServerUri = 'http://localhost/reportserver'
-
- $newReport = Set-FolderReportDataSource($folderPath)
-
- $subscription = Get-NewFileShareSubscription
-
- Set-RsSubscription -ReportServerUri $ReportServerUri -Subscription $subscription -Path $newReport.Path
-
- $reportSubscriptions = Get-RsSubscription -Path $newReport.Path
-
- It "Should set a subscription" {
- @($reportSubscriptions).Count | Should Be 1
- $reportSubscriptions.Report | Should Be "emptyReport"
- $reportSubscriptions.EventType | Should Be "TimedSubscription"
- $reportSubscriptions.IsDataDriven | Should Be $false
- }
- Remove-RsCatalogItem -RsFolder $folderPath
+ AfterEach {
+ Revoke-RsSystemAccess -Identity 'local' -ReportServerUri $reportServerUri
}
- Context "Set-RsSubscription with ReportServerUri and Proxy Parameter"{
- $folderName = 'SutGetRsItemReference_MinParameters' + [guid]::NewGuid()
- $null = New-RsFolder -Path / -FolderName $folderName
- $folderPath = '/' + $folderName
-
- $reportServerUri = 'http://localhost/reportserver'
- $proxy = New-RsWebServiceProxy
-
- $newReport = Set-FolderReportDataSource($folderPath)
-
- $subscription = Get-NewFileShareSubscription
-
- Set-RsSubscription -ReportServerUri $ReportServerUri -Subscription $subscription -Path $newReport.Path -Proxy $proxy
-
- $reportSubscriptions = Get-RsSubscription -Path $newReport.Path
-
- It "Should set a subscription" {
- @($reportSubscriptions).Count | Should Be 1
- $reportSubscriptions.Report | Should Be "emptyReport"
- $reportSubscriptions.EventType | Should Be "TimedSubscription"
- $reportSubscriptions.IsDataDriven | Should Be $false
- }
- Remove-RsCatalogItem -RsFolder $folderPath
+ It "Updates subscription owner" {
+ $rsProxy = New-RsWebServiceProxy -ReportServerUri $reportServerUri
+ Get-RsSubscription -Path $newReport.Path -Proxy $rsProxy | Set-RsSubscription -Owner "LOCAL" -Proxy $rsProxy
+
+ $reportSubscriptions = Get-RsSubscription -Path $newReport.Path -Proxy $rsProxy
+ @($reportSubscriptions).Count | Should Be 1
+ $reportSubscriptions.Report | Should Be "emptyReport"
+ $reportSubscriptions.EventType | Should Be "TimedSubscription"
+ $reportSubscriptions.IsDataDriven | Should Be $false
+ $reportSubscriptions.Owner | Should be "\LOCAL"
}
-}
-Describe "Set-RsSubscription from pipeline" {
- Context "Set-RsSubscription from pipeline without parameters"{
- $folderName = 'SutGetRsItemReference_MinParameters' + [guid]::NewGuid()
- $null = New-RsFolder -Path / -FolderName $folderName
- $folderPath = '/' + $folderName
-
- $newReport = Set-FolderReportDataSource($folderPath)
-
- $subscription = Get-NewFileShareSubscription
-
- #Set first subscription
- Set-RsSubscription -Subscription $subscription -Path $newReport.Path
-
- # Duplicate subscription
- Get-RsSubscription -Path $newReport.Path | Set-RsSubscription -Path $newReport.Path
-
- # Get both subscription
- $reportSubscriptions = Get-RsSubscription -Path $newReport.Path
-
- It "Should set a subscription" {
- @($reportSubscriptions).Count | Should Be 2
- ($reportSubscriptions | Select-Object SubscriptionId -Unique).Count | Should Be 2
- }
- Remove-RsCatalogItem -RsFolder $folderPath
+ It "Updates StartDateTime parameter" {
+ $rsProxy = New-RsWebServiceProxy -ReportServerUri $reportServerUri
+ Get-RsSubscription -Path $newReport.Path -Proxy $rsProxy | Set-RsSubscription -StartDateTime "1/1/1999 6AM" -Proxy $rsProxy
+
+ $reportSubscriptions = Get-RsSubscription -Path $newReport.Path -Proxy $rsProxy
+ @($reportSubscriptions).Count | Should Be 1
+ $reportSubscriptions.Report | Should Be "emptyReport"
+ $reportSubscriptions.EventType | Should Be "TimedSubscription"
+ $reportSubscriptions.IsDataDriven | Should Be $false
+
+ [xml]$XMLMatch = $reportSubscriptions.MatchData
+ $XMLMatch.ScheduleDefinition.StartDateTime.InnerText | Should be (Get-Date -Year 1999 -Month 1 -Day 1 -Hour 6 -Minute 0 -Second 0 -Millisecond 0 -Format 'yyyy-MM-ddTHH:mm:ss.fffzzz')
}
- Context "Set-RsSubscription from pipeline with Proxy parameter"{
- $folderName = 'SutGetRsItemReference_MinParameters' + [guid]::NewGuid()
- $null = New-RsFolder -Path / -FolderName $folderName
- $folderPath = '/' + $folderName
+ It "Updates EndDate parameter" {
+ $rsProxy = New-RsWebServiceProxy -ReportServerUri $reportServerUri
+ Get-RsSubscription -Path $newReport.Path -Proxy $rsProxy | Set-RsSubscription -EndDate 1/1/2999 -Proxy $rsProxy
- $proxy = New-RsWebServiceProxy
+ $reportSubscriptions = Get-RsSubscription -Path $newReport.Path -Proxy $rsProxy
+ @($reportSubscriptions).Count | Should Be 1
+ $reportSubscriptions.Report | Should Be "emptyReport"
+ $reportSubscriptions.EventType | Should Be "TimedSubscription"
+ $reportSubscriptions.IsDataDriven | Should Be $false
- $newReport = Set-FolderReportDataSource($folderPath)
+ [xml]$XMLMatch = $reportSubscriptions.MatchData
+ $XMLMatch.ScheduleDefinition.EndDate.InnerText | Should be "2999-01-01"
+ }
- $subscription = Get-NewFileShareSubscription
+ It "Updates StartDateTime and EndDate parameter" {
+ $rsProxy = New-RsWebServiceProxy -ReportServerUri $reportServerUri
+ Get-RsSubscription -Path $newReport.Path -Proxy $rsProxy | Set-RsSubscription -StartDateTime "1/1/2000 2PM" -EndDate 2/1/2999 -Proxy $rsProxy
- #Set first subscription
- Set-RsSubscription -Subscription $subscription -Path $newReport.Path -Proxy $proxy
-
- # Duplicate subscription
- Get-RsSubscription -Path $newReport.Path | Set-RsSubscription -Path $newReport.Path
-
- # Get both subscription
- $reportSubscriptions = Get-RsSubscription -Path $newReport.Path
+ $reportSubscriptions = Get-RsSubscription -Path $newReport.Path -Proxy $rsProxy
+ @($reportSubscriptions).Count | Should Be 1
+ $reportSubscriptions.Report | Should Be "emptyReport"
+ $reportSubscriptions.EventType | Should Be "TimedSubscription"
+ $reportSubscriptions.IsDataDriven | Should Be $false
- It "Should set a subscription" {
- @($reportSubscriptions).Count | Should Be 2
- ($reportSubscriptions | Select-Object SubscriptionId -Unique).Count | Should Be 2
- }
- Remove-RsCatalogItem -RsFolder $folderPath
+ [xml]$XMLMatch = $reportSubscriptions.MatchData
+ $XMLMatch.ScheduleDefinition.StartDateTime.InnerText | Should be (Get-Date -Year 2000 -Month 1 -Day 1 -Hour 14 -Minute 0 -Second 0 -Millisecond 0 -Format 'yyyy-MM-ddTHH:mm:ss.fffzzz')
+ $XMLMatch.ScheduleDefinition.EndDate.InnerText | Should Be "2999-02-01"
}
+ }
- Context "Set-RsSubscription from pipeline with ReportServerUri Parameter"{
- $folderName = 'SutGetRsItemReference_MinParameters' + [guid]::NewGuid()
- $null = New-RsFolder -Path / -FolderName $folderName
- $folderPath = '/' + $folderName
-
- $reportServerUri = 'http://localhost/reportserver'
-
- $newReport = Set-FolderReportDataSource($folderPath)
-
- $subscription = Get-NewFileShareSubscription
-
- #Set first subscription
- Set-RsSubscription -ReportServerUri $reportServerUri -Subscription $subscription -Path $newReport.Path
-
- # Duplicate subscription
- Get-RsSubscription -Path $newReport.Path | Set-RsSubscription -Path $newReport.Path
-
- # Get both subscription
- $reportSubscriptions = Get-RsSubscription -Path $newReport.Path
-
- It "Should set a subscription" {
- @($reportSubscriptions).Count | Should Be 2
- ($reportSubscriptions | Select-Object SubscriptionId -Unique).Count | Should Be 2
- }
- Remove-RsCatalogItem -RsFolder $folderPath
+ Context "Set-RsSubscription with ReportServerUri parameter" {
+ BeforeEach {
+ Grant-RsSystemRole -Identity 'LOCAL' -RoleName 'System User' -ReportServerUri $reportServerUri
+ Grant-RsCatalogItemRole -Identity 'LOCAL' -RoleName 'Browser' -Path $newReport.path -ReportServerUri $reportServerUri
}
- Context "Set-RsSubscription from pipeline with ReportServerUri and Proxy Parameter"{
- $folderName = 'SutGetRsItemReference_MinParameters' + [guid]::NewGuid()
- $null = New-RsFolder -Path / -FolderName $folderName
- $folderPath = '/' + $folderName
-
- $reportServerUri = 'http://localhost/reportserver'
- $proxy = New-RsWebServiceProxy
-
- $newReport = Set-FolderReportDataSource($folderPath)
-
- $subscription = Get-NewFileShareSubscription
-
- #Set first subscription
- Set-RsSubscription -ReportServerUri $reportServerUri -Proxy $proxy -Subscription $subscription -Path $newReport.Path
-
- # Duplicate subscription
- Get-RsSubscription -Path $newReport.Path | Set-RsSubscription -Path $newReport.Path
-
- # Get both subscription
- $reportSubscriptions = Get-RsSubscription -Path $newReport.Path
-
- It "Should set a subscription" {
- @($reportSubscriptions).Count | Should Be 2
- ($reportSubscriptions | Select-Object SubscriptionId -Unique).Count | Should Be 2
- }
- Remove-RsCatalogItem -RsFolder $folderPath
+ AfterEach {
+ Revoke-RsSystemAccess -Identity 'local' -ReportServerUri $reportServerUri
}
- Context "Set-RsSubscription from pipeline with input from disk"{
- $folderName = 'SutGetRsItemReference_MinParameters' + [guid]::NewGuid()
- $null = New-RsFolder -Path / -FolderName $folderName
- $folderPath = '/' + $folderName
-
- $reportServerUri = 'http://localhost/reportserver'
- $proxy = New-RsWebServiceProxy
-
- $newReport = Set-FolderReportDataSource($folderPath)
-
- $TestPath = 'TestDrive:\Subscription.xml'
-
- $subscription = Get-NewFileShareSubscription
- $subscription | Export-RsSubscriptionXml $TestPath
-
- $subscriptionFromDisk = Import-RsSubscriptionXml $TestPath
-
- #Set first subscription
- Set-RsSubscription -ReportServerUri $reportServerUri -Proxy $proxy -Subscription $subscriptionFromDisk -Path $newReport.Path
-
- # Duplicate subscription
- Get-RsSubscription -Path $newReport.Path | Set-RsSubscription -Path $newReport.Path
-
- # Get both subscription
- $reportSubscriptions = Get-RsSubscription -Path $newReport.Path
-
- It "Should set a subscription" {
- @($reportSubscriptions).Count | Should Be 2
- ($reportSubscriptions | Select-Object SubscriptionId -Unique).Count | Should Be 2
- }
- Remove-RsCatalogItem -RsFolder $folderPath
+ It "Updates subscription owner" {
+ Get-RsSubscription -Path $newReport.Path -ReportServerUri $reportServerUri | Set-RsSubscription -Owner "LOCAL" -ReportServerUri $reportServerUri
+
+ $reportSubscriptions = Get-RsSubscription -Path $newReport.Path -ReportServerUri $reportServerUri
+ @($reportSubscriptions).Count | Should Be 1
+ $reportSubscriptions.Report | Should Be "emptyReport"
+ $reportSubscriptions.EventType | Should Be "TimedSubscription"
+ $reportSubscriptions.IsDataDriven | Should Be $false
+ $reportSubscriptions.Owner | Should be "\LOCAL"
+ }
+
+ It "Updates StartDateTime parameter" {
+ $rsProxy = New-RsWebServiceProxy -ReportServerUri $reportServerUri
+ Get-RsSubscription -Path $newReport.Path -ReportServerUri $reportServerUri | Set-RsSubscription -StartDateTime "1/1/1999 6AM" -ReportServerUri $reportServerUri
+
+ $reportSubscriptions = Get-RsSubscription -Path $newReport.Path -ReportServerUri $reportServerUri
+ @($reportSubscriptions).Count | Should Be 1
+ $reportSubscriptions.Report | Should Be "emptyReport"
+ $reportSubscriptions.EventType | Should Be "TimedSubscription"
+ $reportSubscriptions.IsDataDriven | Should Be $false
+
+ [xml]$XMLMatch = $reportSubscriptions.MatchData
+ $XMLMatch.ScheduleDefinition.StartDateTime.InnerText | Should be (Get-Date -Year 1999 -Month 1 -Day 1 -Hour 6 -Minute 0 -Second 0 -Millisecond 0 -Format 'yyyy-MM-ddTHH:mm:ss.fffzzz')
+ }
+
+ It "Updates EndDate parameter" {
+ $rsProxy = New-RsWebServiceProxy -ReportServerUri $reportServerUri
+ Get-RsSubscription -Path $newReport.Path -ReportServerUri $reportServerUri | Set-RsSubscription -EndDate 1/1/2999 -ReportServerUri $reportServerUri
+
+ $reportSubscriptions = Get-RsSubscription -Path $newReport.Path -ReportServerUri $reportServerUri
+ @($reportSubscriptions).Count | Should Be 1
+ $reportSubscriptions.Report | Should Be "emptyReport"
+ $reportSubscriptions.EventType | Should Be "TimedSubscription"
+ $reportSubscriptions.IsDataDriven | Should Be $false
+
+ [xml]$XMLMatch = $reportSubscriptions.MatchData
+ $XMLMatch.ScheduleDefinition.EndDate.InnerText | Should be "2999-01-01"
}
-}
+ It "Updates StartDateTime and EndDate parameter" {
+ $rsProxy = New-RsWebServiceProxy -ReportServerUri $reportServerUri
+ Get-RsSubscription -Path $newReport.Path -ReportServerUri $reportServerUri | Set-RsSubscription -StartDateTime "1/1/2000 2PM" -EndDate 2/1/2999 -ReportServerUri $reportServerUri
+ $reportSubscriptions = Get-RsSubscription -Path $newReport.Path -ReportServerUri $reportServerUri
+ @($reportSubscriptions).Count | Should Be 1
+ $reportSubscriptions.Report | Should Be "emptyReport"
+ $reportSubscriptions.EventType | Should Be "TimedSubscription"
+ $reportSubscriptions.IsDataDriven | Should Be $false
+
+ [xml]$XMLMatch = $reportSubscriptions.MatchData
+ $XMLMatch.ScheduleDefinition.StartDateTime.InnerText | Should be (Get-Date -Year 2000 -Month 1 -Day 1 -Hour 14 -Minute 0 -Second 0 -Millisecond 0 -Format 'yyyy-MM-ddTHH:mm:ss.fffzzz')
+ $XMLMatch.ScheduleDefinition.EndDate.InnerText | Should Be "2999-02-01"
+ }
+ }
+}
diff --git a/Tests/CatalogItems/Update-RsSubscription.Tests.ps1 b/Tests/CatalogItems/Update-RsSubscription.Tests.ps1
deleted file mode 100644
index 1b3ddaec..00000000
--- a/Tests/CatalogItems/Update-RsSubscription.Tests.ps1
+++ /dev/null
@@ -1,307 +0,0 @@
-# Copyright (c) 2016 Microsoft Corporation. All Rights Reserved.
-# Licensed under the MIT License (MIT)
-
-#Not in use right now - need email configuration on the report server
-Function Get-NewSubscription
-{
-
- [xml]$matchData = '2017-07-14T08:00:00.000+01:001truetruetruetruetrue'
-
- $proxy = New-RsWebServiceProxy
- $namespace = $proxy.GetType().NameSpace
-
- $ExtensionSettingsDataType = "$namespace.ExtensionSettings"
- $ParameterValueOrFieldReference = "$namespace.ParameterValueOrFieldReference[]"
- $ParameterValueDataType = "$namespace.ParameterValue"
-
- #Set ExtensionSettings
- $ExtensionSettings = New-Object $ExtensionSettingsDataType
-
- $ExtensionSettings.Extension = "Report Server Email"
-
- #Set ParameterValues
- $ParameterValues = New-Object $ParameterValueOrFieldReference -ArgumentList 8
-
- $to = New-Object $ParameterValueDataType
- $to.Name = "TO";
- $to.Value = "mail@rstools.com";
- $ParameterValues[0] = $to;
-
- $replyTo = New-Object $ParameterValueDataType
- $replyTo.Name = "ReplyTo";
- $replyTo.Value ="dank@rstools.com";
- $ParameterValues[1] = $replyTo;
-
- $includeReport = New-Object $ParameterValueDataType
- $includeReport.Name = "IncludeReport";
- $includeReport.Value = "False";
- $ParameterValues[2] = $includeReport;
-
- $renderFormat = New-Object $ParameterValueDataType
- $renderFormat.Name = "RenderFormat";
- $renderFormat.Value = "MHTML";
- $ParameterValues[3] = $renderFormat;
-
- $priority = New-Object $ParameterValueDataType
- $priority.Name = "Priority";
- $priority.Value = "NORMAL";
- $ParameterValues[4] = $priority;
-
- $subject = New-Object $ParameterValueDataType
- $subject.Name = "Subject";
- $subject.Value = "Your sales report";
- $ParameterValues[5] = $subject;
-
- $comment = New-Object $ParameterValueDataType
- $comment.Name = "Comment";
- $comment.Value = "Here is the link to your report.";
- $ParameterValues[6] = $comment;
-
- $includeLink = New-Object $ParameterValueDataType
- $includeLink.Name = "IncludeLink";
- $includeLink.Value = "True";
- $ParameterValues[7] = $includeLink;
-
- $ExtensionSettings.ParameterValues = $ParameterValues
-
- $subscription = [pscustomobject]@{
- DeliverySettings = $ExtensionSettings
- Description = "Send email to mail@rstools.com"
- EventType = "TimedSubscription"
- IsDataDriven = $false
- MatchData = $matchData.OuterXml
- }
-
- return $subscription
-}
-
-Function Get-NewFileShareSubscription
-{
-
- [xml]$matchData = '2017-07-14T08:00:00.000+01:001truetruetruetruetrue'
-
- $proxy = New-RsWebServiceProxy
- $namespace = $proxy.GetType().NameSpace
-
- $ExtensionSettingsDataType = "$namespace.ExtensionSettings"
- $ParameterValueOrFieldReference = "$namespace.ParameterValueOrFieldReference[]"
- $ParameterValueDataType = "$namespace.ParameterValue"
-
- #Set ExtensionSettings
- $ExtensionSettings = New-Object $ExtensionSettingsDataType
-
- $ExtensionSettings.Extension = "Report Server FileShare"
-
- #Set ParameterValues
- $ParameterValues = New-Object $ParameterValueOrFieldReference -ArgumentList 7
-
- $to = New-Object $ParameterValueDataType
- $to.Name = "PATH";
- $to.Value = "\\unc\path";
- $ParameterValues[0] = $to;
-
- $replyTo = New-Object $ParameterValueDataType
- $replyTo.Name = "FILENAME";
- $replyTo.Value ="Report";
- $ParameterValues[1] = $replyTo;
-
- $includeReport = New-Object $ParameterValueDataType
- $includeReport.Name = "FILEEXTN";
- $includeReport.Value = "True";
- $ParameterValues[2] = $includeReport;
-
- $renderFormat = New-Object $ParameterValueDataType
- $renderFormat.Name = "USERNAME";
- $renderFormat.Value = "user";
- $ParameterValues[3] = $renderFormat;
-
- $priority = New-Object $ParameterValueDataType
- $priority.Name = "RENDER_FORMAT";
- $priority.Value = "PDF";
- $ParameterValues[4] = $priority;
-
- $subject = New-Object $ParameterValueDataType
- $subject.Name = "WRITEMODE";
- $subject.Value = "Overwrite";
- $ParameterValues[5] = $subject;
-
- $comment = New-Object $ParameterValueDataType
- $comment.Name = "DEFAULTCREDENTIALS";
- $comment.Value = "False";
- $ParameterValues[6] = $comment;
-
- $ExtensionSettings.ParameterValues = $ParameterValues
-
- $subscription = [pscustomobject]@{
- DeliverySettings = $ExtensionSettings
- Description = "Shared on \\unc\path"
- EventType = "TimedSubscription"
- IsDataDriven = $false
- MatchData = $matchData.OuterXml
- }
-
- return $subscription
-}
-
-Function Set-FolderReportDataSource
-{
- param (
- [string]
- $NewFolderPath
- )
-
-
- $localResourcesPath = (Get-Item -Path ".\").FullName + '\Tests\CatalogItems\testResources\emptyReport.rdl'
- $null = Write-RsCatalogItem -Path $localResourcesPath -RsFolder $NewFolderPath
- $report = (Get-RsFolderContent -RsFolder $NewFolderPath )| Where-Object TypeName -eq 'Report'
-
- $localResourcesPath = (Get-Item -Path ".\").FullName + '\Tests\CatalogItems\testResources\UnDataset.rsd'
- $null = Write-RsCatalogItem -Path $localResourcesPath -RsFolder $NewFolderPath
- $dataSet = (Get-RsFolderContent -RsFolder $NewFolderPath ) | Where-Object TypeName -eq 'DataSet'
- $DataSetPath = $NewFolderPath + '/UnDataSet'
-
- $newRSDSName = "DataSource"
- $newRSDSExtension = "SQL"
- $newRSDSConnectionString = "Initial Catalog=DB; Data Source=Instance"
- $newRSDSCredentialRetrieval = "Store"
- #Dummy credentials
- $Pass = ConvertTo-SecureString -String "123" -AsPlainText -Force
- $newRSDSCredential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList "sql", $Pass
- $null = New-RsDataSource -RsFolder $NewFolderPath -Name $newRSDSName -Extension $newRSDSExtension -ConnectionString $newRSDSConnectionString -CredentialRetrieval $newRSDSCredentialRetrieval -DatasourceCredentials $newRSDSCredential
-
- $DataSourcePath = "$NewFolderPath/$newRSDSName"
-
- $RsDataSet = Get-RsItemReference -Path $report.Path | Where-Object ReferenceType -eq 'DataSet'
- $RsDataSource = Get-RsItemReference -Path $report.Path | Where-Object ReferenceType -eq 'DataSource'
- $RsDataSetSource = Get-RsItemReference -Path $DataSetPath | Where-Object ReferenceType -eq 'DataSource'
-
- #Set data source and data set for all objects
- $null = Set-RsDataSourceReference -Path $DataSetPath -DataSourceName $RsDataSetSource.Name -DataSourcePath $DataSourcePath
- $null = Set-RsDataSourceReference -Path $report.Path -DataSourceName $RsDataSource.Name -DataSourcePath $DataSourcePath
- $null = Set-RsDataSetReference -Path $report.Path -DataSetName $RsDataSet.Name -DataSetPath $dataSet.Path
-
- return $report
-}
-
-Describe "Update-RsSubscription" {
- Context "Update-RsSubscription piped from get-subscription with Owner parameter"{
- $folderName = 'SutGetRsItemReference_MinParameters' + [guid]::NewGuid()
- $null = New-RsFolder -Path / -FolderName $folderName
- $folderPath = '/' + $folderName
-
- $newReport = Set-FolderReportDataSource($folderPath)
-
- Grant-RsSystemRole -Identity 'LOCAL' -RoleName 'System User'
-
- $subscription = Get-NewFileShareSubscription
-
- Set-RsSubscription -Subscription $subscription -Path $newReport.Path
-
- Grant-RsCatalogItemRole -Identity 'LOCAL' -RoleName 'Browser' -path $newReport.path
-
- Get-RsSubscription -Path $newReport.Path | Update-RsSubscription -Owner "LOCAL"
-
- $reportSubscriptions = Get-RsSubscription -Path $newReport.Path
-
- [xml]$XMLMatch = $reportSubscriptions.MatchData
-
- It "Should set a subscription" {
- @($reportSubscriptions).Count | Should Be 1
- $reportSubscriptions.Report | Should Be "emptyReport"
- $reportSubscriptions.EventType | Should Be "TimedSubscription"
- $reportSubscriptions.IsDataDriven | Should Be $false
- $reportSubscriptions.Owner | Should be "\LOCAL"
- }
- Remove-RsCatalogItem -RsFolder $folderPath
- Revoke-RsSystemAccess -Identity 'local'
- }
-
- Context "Update-RsSubscription piped from get-subscription with StartDateTime parameter"{
- $folderName = 'SutGetRsItemReference_MinParameters' + [guid]::NewGuid()
- $null = New-RsFolder -Path / -FolderName $folderName
- $folderPath = '/' + $folderName
-
- $newReport = Set-FolderReportDataSource($folderPath)
-
- $subscription = Get-NewFileShareSubscription
-
- Set-RsSubscription -Subscription $subscription -Path $newReport.Path
-
- Get-RsSubscription -Path $newReport.Path | Update-RsSubscription -StartDateTime "1/1/1999 6AM"
-
- $reportSubscriptions = Get-RsSubscription -Path $newReport.Path
-
- [xml]$XMLMatch = $reportSubscriptions.MatchData
-
- It "Should set a subscription" {
- @($reportSubscriptions).Count | Should Be 1
- $reportSubscriptions.Report | Should Be "emptyReport"
- $reportSubscriptions.EventType | Should Be "TimedSubscription"
- $reportSubscriptions.IsDataDriven | Should Be $false
- $XMLMatch.ScheduleDefinition.StartDateTime.InnerText | Should be "1999-01-01T06:00:00.000+00:00"
- }
- Remove-RsCatalogItem -RsFolder $folderPath
- }
-
- Context "Update-RsSubscription piped from get-subscription with EndDate parameter with poxy"{
- $folderName = 'SutGetRsItemReference_MinParameters' + [guid]::NewGuid()
- $null = New-RsFolder -Path / -FolderName $folderName
- $folderPath = '/' + $folderName
-
- $proxy = New-RsWebServiceProxy
-
- $newReport = Set-FolderReportDataSource($folderPath)
-
- $subscription = Get-NewFileShareSubscription
-
- Set-RsSubscription -Subscription $subscription -Path $newReport.Path -Proxy $proxy
-
-
- Get-RsSubscription -Path $newReport.Path | Update-RsSubscription -EndDate 1/1/2999
-
- $reportSubscriptions = Get-RsSubscription -Path $newReport.Path
-
- [xml]$XMLMatch = $reportSubscriptions.MatchData
-
- It "Should set a subscription" {
- @($reportSubscriptions).Count | Should Be 1
- $reportSubscriptions.Report | Should Be "emptyReport"
- $reportSubscriptions.EventType | Should Be "TimedSubscription"
- $reportSubscriptions.IsDataDriven | Should Be $false
- $XMLMatch.ScheduleDefinition.EndDate.InnerText | Should Be "2999-01-01"
- }
- Remove-RsCatalogItem -RsFolder $folderPath
- }
-
- Context "Update-RsSubscription piped from get-subscription with StartDateTime and EndDate Paramter with ReportServerURI"{
- $folderName = 'SutGetRsItemReference_MinParameters' + [guid]::NewGuid()
- $null = New-RsFolder -Path / -FolderName $folderName
- $folderPath = '/' + $folderName
-
- $reportServerUri = 'http://localhost/reportserver'
-
- $newReport = Set-FolderReportDataSource($folderPath)
-
- $subscription = Get-NewFileShareSubscription
-
- Set-RsSubscription -ReportServerUri $ReportServerUri -Subscription $subscription -Path $newReport.Path
-
- Get-RsSubscription -Path $newReport.Path | Update-RsSubscription -StartDateTime "1/1/2000 2PM" -EndDate 2/1/2999
-
- $reportSubscriptions = Get-RsSubscription -Path $newReport.Path
-
- [xml]$XMLMatch = $reportSubscriptions.MatchData
-
- It "Should set a subscription" {
- @($reportSubscriptions).Count | Should Be 1
- $reportSubscriptions.Report | Should Be "emptyReport"
- $reportSubscriptions.EventType | Should Be "TimedSubscription"
- $reportSubscriptions.IsDataDriven | Should Be $false
- $XMLMatch.ScheduleDefinition.StartDateTime.InnerText | Should be "2000-01-01T14:00:00.000+00:00"
- $XMLMatch.ScheduleDefinition.EndDate.InnerText | Should Be "2999-02-01"
- }
- Remove-RsCatalogItem -RsFolder $folderPath
- }
-
-
-}
diff --git a/Tests/CatalogItems/Write-RsCatalogItem.Tests.ps1 b/Tests/CatalogItems/Write-RsCatalogItem.Tests.ps1
index cc0c7e37..474b9fbe 100644
--- a/Tests/CatalogItems/Write-RsCatalogItem.Tests.ps1
+++ b/Tests/CatalogItems/Write-RsCatalogItem.Tests.ps1
@@ -30,7 +30,7 @@ Describe "Write-RsCatalogItem" {
$uploadedDataSet.Name | Should Be 'UnDataset'
}
# Removing folders used for testing
- Remove-RsCatalogItem -RsFolder $folderPath
+ Remove-RsCatalogItem -RsFolder $folderPath -Confirm:$false
}
Context "Write-RsCatalogItem with Proxy parameter"{
@@ -46,7 +46,7 @@ Describe "Write-RsCatalogItem" {
$uploadedReport.Name | Should Be 'emptyReport'
}
# Removing folders used for testing
- Remove-RsCatalogItem -RsFolder $folderPath
+ Remove-RsCatalogItem -RsFolder $folderPath -Confirm:$false
}
Context "Write-RsCatalogItem with Proxy and ReportServerUri parameter"{
@@ -63,7 +63,7 @@ Describe "Write-RsCatalogItem" {
$uploadedReport.Name | Should Be 'emptyReport'
}
# Removing folders used for testing
- Remove-RsCatalogItem -RsFolder $folderPath
+ Remove-RsCatalogItem -RsFolder $folderPath -Confirm:$false
}
Context "Write-RsCatalogItem with ReportServerUri parameter"{
@@ -79,7 +79,7 @@ Describe "Write-RsCatalogItem" {
$uploadedReport.Name | Should Be 'emptyReport'
}
# Removing folders used for testing
- Remove-RsCatalogItem -RsFolder $folderPath
+ Remove-RsCatalogItem -RsFolder $folderPath -Confirm:$false
}
Context "Write-RsCatalogItem with Overwrite parameter"{
@@ -97,6 +97,6 @@ Describe "Write-RsCatalogItem" {
$overwrittenReport.Name | Should Be 'emptyReport'
}
# Removing folders used for testing
- Remove-RsCatalogItem -RsFolder $folderPath
+ Remove-RsCatalogItem -RsFolder $folderPath -Confirm:$false
}
}
\ No newline at end of file
diff --git a/Tests/CatalogItems/Write-RsFolderContent.Tests.ps1 b/Tests/CatalogItems/Write-RsFolderContent.Tests.ps1
index 2ffa3d0f..10c61980 100644
--- a/Tests/CatalogItems/Write-RsFolderContent.Tests.ps1
+++ b/Tests/CatalogItems/Write-RsFolderContent.Tests.ps1
@@ -25,7 +25,7 @@ Describe "Write-RsFolderContent" {
$uploadedDataSet.Name | Should Be 'UnDataset'
}
# Removing folders used for testing
- Remove-RsCatalogItem -RsFolder $folderPath
+ Remove-RsCatalogItem -RsFolder $folderPath -Confirm:$false
}
Context "Write-RsFolderContent with ReportServerUri parameter"{
@@ -40,7 +40,7 @@ Describe "Write-RsFolderContent" {
$uploadedReport.Name | Should Be 'emptyReport'
}
# Removing folders used for testing
- Remove-RsCatalogItem -RsFolder $folderPath
+ Remove-RsCatalogItem -RsFolder $folderPath -Confirm:$false
}
Context "Write-RsFolderContent with Proxy Parameter"{
@@ -55,7 +55,7 @@ Describe "Write-RsFolderContent" {
$uploadedReport.Name | Should Be 'emptyReport'
}
# Removing folders used for testing
- Remove-RsCatalogItem -RsFolder $folderPath
+ Remove-RsCatalogItem -RsFolder $folderPath -Confirm:$false
}
Context "Write-RsFolderContent with Proxy and ReportServerUri"{
@@ -71,7 +71,7 @@ Describe "Write-RsFolderContent" {
$uploadedReport.Name | Should Be 'emptyReport'
}
# Removing folders used for testing
- Remove-RsCatalogItem -RsFolder $folderPath
+ Remove-RsCatalogItem -RsFolder $folderPath -Confirm:$false
}
Context "Write-RsFolderContent with Recurse Parameter"{
@@ -102,6 +102,6 @@ Describe "Write-RsFolderContent" {
$uploadedDataSet.Name | Should Be 'UnDataset'
}
# Removing folders used for testing
- Remove-RsCatalogItem -RsFolder $folderPath
+ Remove-RsCatalogItem -RsFolder $folderPath -Confirm:$false
}
}
\ No newline at end of file