Moving SSRS Subscriptions with PowerShell - powershell

I am trying to move SSRS Subscriptions between servers. The report has already been moved to the new server. I've seen multiple blog posts which seem to indicate this is possible. HOwever, they rely on an the powershell command
set-RsSubscription -path
and on my powershell, that parameter doesn't exist.
the overall script looks something like this:
Get-RsSubscription -ReportServerUri "http://testserver/reportserver" -Credential $credential -path "/Reports/Report 1" |
Set-RsSubscription -ReportServerUri -path "/Reports/Report 1" `
the set-rssubscription -path isn't accepted.
Note that I am on SQL Server 2016 on both servers. Reporting Services tools are at 0.0.4.6.

It looks like there has been a change to Set-RsSubscription:
"There was a major breaking release on v0.0.4.0 which means that my scripts on this blog post may not work. In fact, the Set-RsSubscription is one of them. If you use the Get-Help Set-RsSubscription you can see that -Path parameter no longer exists. This command, as it is today just work to set some subscription properties. The command you are looking for is the Copy-RSSubscription. Please take a look at the examples provided with the help. I leave here just one:
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'
http://redglue.eu/does-that-copy-subscriptions-too-now-it-does-new-powershell-ssrs-commands/
Also, currently you may run into issues with Copy-RSSubscription
https://github.com/Microsoft/ReportingServicesTools/issues/172

Related

Running powershell without useriteraction

start "odopen://sync/?siteId=$siteid17&webId=$webid17&listId=$listid17&userEmail=$upn&webUrl=$URL17&webtitle=$webtitle17&listtitle=$listtitle17"
How is it possible to run the following command inside Powershell without an appearing popup window or any userinteraction? I've tried adding /ArgumentList "/S", "/Background". Also tried with -WindowStyle Hidden at the end. Appreciate some help :)
Your command as-is basically says "Start the program that opens odopen:// (OneDrive) links" and can't really be given any silent style instructions. The proper way to configure this kind of thing is through OneDrive Group Policies, but we can cheat and set registry keys.
The link above goes into detail about how to configure group policy, but also tells us that the specific group policy setting to "Configure team site libraries to sync automatically" sets this registry key:
[HKCU\Software\Policies\Microsoft\OneDrive\TenantAutoMount]"LibraryName"="LibraryID"
And that your LibraryID is in this format, which looks familiar:
tenantId=xxx&siteId=xxx&webId=xxx&listId=xxx&webUrl=httpsxxx&version=1
So to put it in a script, I would use something like this, adapted from Nicola Suter's blog post here:
$tenantAutoMountRegKey = "HKLM:\SOFTWARE\Policies\Microsoft\OneDrive\TenantAutoMount"
$autoMountTeamSitesList= #{
#Enter your SharePoint libraries to configure here as key/value pairs
MySharePoint="odopen://sync/?siteId=$siteid17&webId=$webid17&listId=$listid17&userEmail=$upn&webUrl=$URL17&webtitle=$webtitle17&listtitle=$listtitle17"
}
# Check if the key exists and create if missing:
if (-not (Test-Path $tenantAutoMountRegKey)){ New-Item -Path $tenantAutoMountRegKey -Force }
# Add the sites for automatic mounting
$autoMountTeamSitesList | Set-ItemProperty -Path $tenantAutoMountRegKey -Name $_.Key -Value $_.Value
This generally takes effect the next time a user signs into OneDrive, though Microsoft warns it may take up to 8 hours to start syncing (Keeps hundreds of users from syncing the same library at the same time)
TL;DR: You cannot.
Using odopen will always show sign-in window (as stated here: https://learn.microsoft.com/en-us/onedrive/deploy-on-windows#help-users-sign-in), what you can do is only populate it with data, which is what you are already doing.
If you want to do it silently, there is documentation about it: https://learn.microsoft.com/en-us/onedrive/use-silent-account-configuration

Error while setting the DenyAddAndCustomizePages property of tenant site using PnP Powershell

I am trying to set DenyAddAndCustomizePages property of my tenant site using the script below but it gives an error. What should be the alternative for using it with new PnP.Powershell module? Our project was running for several months with SharepointPnPPowershell But as this is now deprecated and not supported anymore, after installing PnP. Powershell we are seeing lots of issues.
Method invocation failed because [PnP.PowerShell.Commands.Model.SPOSite] does not contain a method named 'update'.
I tried to include Import-Module Microsoft.Online.SharePoint.PowerShell -Scope "Local" as described at the end of the article below but that did not work.
https://learn.microsoft.com/en-us/answers/questions/258967/problems-with-update-method-to-change-conditional.html
$site = Get-PnPTenantSite -Detailed -Url $Url
$site.DenyAddAndCustomizePages = "Disabled"
$site.Update() | Out-Null
I'm guessing you found the answer by now? If not, have you tried this?
Set-PnpTenantSite -Identity $siteUrl -DenyAddAndCustomizePages:$false | Out-Null
Tks.
Alex

How can I find the Microsoft Edge version on Windows 10 in powershell?

I've searched through the SOFTWARE\Classes and SOFTWARE\Microsoft subkeys, but couldn't find anything related to "spartan" or "edge". Given that Edge is still very new, there really isn't much information about this yet.
As an example, this is how I gather the information about the Internet Explorer Version via the registry on a remote machine:
$ieVersion=[Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $args[0]).OpenSubKey('SOFTWARE\Microsoft\Internet Explorer').GetValue('SvcVersion')
Use the Get-AppxPackage command:
Get-AppxPackage -Name Microsoft.MicrosoftEdge | Foreach Version
The package name is valid on build 10240 but if you are on an earlier build, it might be different. If the above doesn't find the package try -Name *Edge* or -Name *Spartan*.
$productPath = $Env:WinDir + "\SystemApps\Microsoft.MicrosoftEdge_*\MicrosoftEdge.exe"
If(Test-Path $productPath) {
$productProperty = Get-ItemProperty -Path $productPath
Write-Host $productProperty.VersionInfo.ProductVersion
}
Else {
Write-Host "Not find Microsoft Edge."
}
Source How to determine the version of Microsoft Edge browser by PowerShell
For Edge on Chromium above 44 version
powershell:
Get-AppxPackage -Name *MicrosoftEdge.* | Foreach Version
cmd:
powershell "Get-AppxPackage -Name *MicrosoftEdge.* | Foreach Version"
I tested using two commands back to back. I ran from an elevated PowerShell session New-PSSession -ComputerName "The remote PC I was testing this on." and then once the connection was made I ran the Get-AppxPackage -Name Microsoft.MicsrosoftEdge and it pulled down the information, but I think it was more build information. You can also filter it down to version using the Pipe character. The full command looked like this.
Get-AppxPackage -Name Microsoft.MicrosoftEdge | select-object Version
I found this forum and others that lead me to some of the other switches and parameters I did not know about.
How can I find the Microsoft Edge version on Windows 10 in powershell?
I was trying to find an alternate way of remotely finding out what browser version it was. Trying to verify if it is updating regularly. I am still learning. I hope this helps. I found another article that shows me exactly what I am looking for differently without powershell.
https://www.tenforums.com/tutorials/161325-how-find-version-microsoft-edge-chromium-installed.html#option2
You may see multiple versions of Edge installed via Appx-Packages. I would recommend this approach:
$EdgeExe = Get-ItemPropertyValue 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\msedge.exe' "(default)"
$version = (Get-Item $EdgeExe).VersionInfo.ProductVersion

Configure SharePoint 2010 UPS with PowerShell

SOLUTION FOUND: For anyone else that happens to come across this problem, have a look-see at this: http://www.harbar.net/archive/2010/10/30/avoiding-the-default-schema-issue-when-creating-the-user-profile.aspx
TL;DR When you create UPS through CA, it creates a dbo user and schema on the SQL server using the farm account, however when doing it through powershell it creates it with a schema and user named after the farm account, but still tries to manage SQL using the dbo schema, which of course fails terribly.
NOTE: I've only included the parts of my script I believe to be relevant. I can provide other parts as needed.
I'm at my wit's end on this one. Everything seems to work fine, except the UPS Synchronization service is stuck on "Starting", and I've left it over 12 hours.
It works fine when it's set up through the GUI, but I'm trying to automate every step possible. While automating I'm trying to include every option available from the GUI so that it's present if it ever needs to be changed.
Here's what I have so far:
$domain = "DOMAIN"
$fqdn = "fully.qualified.domain.name"
$admin_pass = "password"
New-SPManagedPath "personal" -WebApplication "http://portal.$($fqdn):9000/"
$upsPool = New-SPServiceApplicationPool -Name "SharePoint - UPS" -Account "$domain\spsvc"
$upsApp = New-SPProfileServiceApplication -Name "UPS" -ApplicationPool $upsPool -MySiteLocation "http://portal.$($fqdn):9000/" -MySiteManagedPath "personal" -ProfileDBName "UPS_ProfileDB" -ProfileSyncDBName "UPS_SyncDB" -SocialDBName "UPS_SocialDB" -SiteNamingConflictResolution "None"
New-SPProfileServiceApplicationProxy -ServiceApplication $upsApp -Name "UPS Proxy" -DefaultProxyGroup
$upsServ = Get-SPServiceInstance | Where-Object {$_.TypeName -eq "User Profile Service"}
Start-SPServiceInstance $upsServ.Id
$upsSync = Get-SPServiceInstance | Where-Object {$_.TypeName -eq "User Profile Synchronization Service"}
$upsApp.SetSynchronizationMachine("Portal", $upsSync.Id, "$domain\spfarm", $admin_pass)
$upsApp.Update()
Start-SPServiceInstance $upsSync.Id
I've tried running each line one at a time by just copying it directly into the shell window after defining the variables, and none of them give an error, but there has to be something the CA GUI does that I'm missing.
For anyone else that happens to come across this problem, have a look-see at this: http://www.harbar.net/archive/2010/10/30/avoiding-the-default-schema-issue-when-creating-the-user-profile.aspx
TL;DR When you create UPS through CA, it creates a dbo user and schema on the SQL server using the farm account, however when doing it through powershell it creates it with a schema and user named after the farm account, but still tries to manage SQL using the dbo schema, which of course fails terribly.
The workaround is to put my code into its own script file, and then use Start-Process to run the script as the farm account (it's a lot cleaner than the Job method described in the linked article):
$credential = Get-Credential ("$domain\spfarm", $SecureString)
Start-Process -FilePath powershell.exe -ArgumentList "-File C:\upsSync.ps1" -Credential $credential

Merge-SPLogFile- Doesn't return me any records

thanks for taking the time to try any help me out!
As the title suggests I cannot get the Merge-SPLogFile cmdlet to return me any results!
I find hunting down error messages in SharePoint logs a very time consuming and laborious process- Being relatively new to PowerShell I only recently stumbled across the cmdlet. Knowing how much time this could save me I was excited to implement it.
I started with the following code:
Add-PSSnapin Microsoft.SharePoint.Powershell
$correlationId = "C826869C-4A8E-10E2-6C5E-58A1C87EB651"
Merge-SPLogFile –Path “C:\Users\Administrator\Desktop\SPLog.log” –Correlation $correlationId -Overwrite
This gives me the warning- "WARNING: Cmdlet did not return any records in the log file. Check your time range or filters."
Naturally I typed the error into my search engine and it seems other people have had the same problems when the -Correlation argument isn't in upper case. I tried both uppercase and lowercase but to no avail. I was able to manually find the GUID in the logs so I know it exists.
When I ran out of luck with this technique I thought I would try filtering using different arguments (by time):
Add-PSSnapin Microsoft.SharePoint.Powershell
[int] $HowFarBack = 15
[int] $howFarBackInMinutes = (-1) * $HowFarBack
[datetime] $startDateTime = [System.DateTime]::Now.AddMinutes($howFarBackInMinutes)
write-host $startDateTime
Merge-SPLogFile -Path 'C:\Users\Administrator\Desktop\SPLog.log' -Overwrite -StartTime $startDateTime
I get exactly the same error. To rule out my arguments being incorrect I tried not giving it a filter at all:
Add-PSSnapin Microsoft.SharePoint.Powershell
Merge-SPLogFile -Path 'C:\Users\Administrator\Desktop\SPLog.log' -Overwrite
I still get- "WARNING: Cmdlet did not return any records in the log file. Check your time range or filters." The logs are all there and in the default "LOG" folder within the 15 hive. I haven't changed any logging settings away from the defaults.
I am running on SharePoint 2013 Foundation.
What am I doing wrong?
The problem in my case was that there was no diagnostic logging activated for my SharePoint Farm.
How to enable diagnostic logging
Go to your Central Administration (usually http://YOUR_SHAREPOINT:10000/) (there is also a shortcut in your start menu on the server you installed the SharePoint at)
Go to "Monitoring"
Under "Reporting" click "Configure diagnostic logging"
Select the categories that you want to merge in case of an Error. I just selected All Categories here. Then click the "Ok" button at the bottom of the page.
(5. Reproduce the error and use the SP Shell again to Merge the Log Files)