Friday, February 26, 2016

Getting SSRS Charts to export to a shared file folder

We have a system here at the office that displays .jpg's on screens throughout the organization.  We use this to communicate goings on to people that are traveling through the breakrooms and hallways of the building.  Recently we wanted to show some SSRS reports on these screens.  The problem is that the devices that display the images do not use any sort of authentication and cannot tie into our SharePoint farm.  I had to figure out how we could produce a .jpg/.png file from a report and drop it into a file folder on the network.

This is not something you need everyday, but for those that need it, here is how I did it.

Firstly, my SharePoint/SSRS installation did not even have the option to export to a jpeg, so I relied on the below to get that working.

http://social.technet.microsoft.com/wiki/contents/articles/20825.ssrs-how-to-add-jpeg-and-png-report-export-when-ssrs-2012-is-integrated-with-sharepoint-2013.aspx


SQL Server Reporting Services (SSRS) does not include export to JPEG or PNG in the SharePoint report viewer web part by default,  even though SSRS supports report rendering in these formats.  For standalone SSRS servers you can enable this capability by editing the RSReportServer.config file (http://technet.microsoft.com/en-us/library/ms157273.aspx#bkmk_rendering This link is external to TechNet Wiki. It will open in a new window. ), but this does not work for SSRS integrated with SharePoint.

1. Get your application ID (GUID):    
Get-SPRSServiceApplication
2. Add the extensions:
New-SPRSExtension -identity "{INSERT YOUR APPLICATION ID HERE}" -ExtensionType "Render" -name "JPEG" -TypeName "Microsoft.ReportingServices.Rendering.ImageRenderer.ImageRenderer,Microsoft.ReportingServices.ImageRendering" -ServerDirectives "<OverrideNames><Name
 Language='en-US'>JPEG</Name></OverrideNames>" -ExtensionConfiguration "<DeviceInfo><OutputFormat>JPEG</OutputFormat></DeviceInfo>"            
 New-SPRSExtension -identity "{INSERT YOUR APPLICATION ID HERE}" -ExtensionType "Render" -name "PNG" -TypeName "Microsoft.ReportingServices.Rendering.ImageRenderer.ImageRenderer,Microsoft.ReportingServices.ImageRendering" -ServerDirectives "<OverrideNames><Name
 Language='en-US'>PNG</Name></OverrideNames>" -ExtensionConfiguration "<DeviceInfo><OutputFormat>PNG</OutputFormat></DeviceInfo>"
3. You can list the loaded Render extensions:
Get-SPRSExtension -Identity "{INSERT YOUR APPLICATION ID HERE}" -ExtensionType "Render"
4: If you make a mistake you can remove them with:
Remove-SPRSExtension -Identity "{INSERT YOUR APPLICATION ID HERE}" -ExtensionType "Render" -Name PNG

Secondly, the report was not saved in a format that fit the screen.  I had to go into the report and fiddle with the page setup options to align the print out to fit the screen.  This is something you will need to do when building the report.

Finally, you will need to set up a subscription via "Manage Subscriptions" on the report in SharePoint.  In this area you need to give it the location where you will save your .jpg or .png.  

This is where it got tricky.
Even though the person running the report had full access to both the library in SharePoint and the folder on the network, we still got a permissions error when the subscription ran.

It ends up that the account running the report needs local log in rights on the SharePoint server running the SSRS service to perform the action we are attempting.  We didn't want to allow anyone trying to run a report to do this access to the server, so we created a service account that had these rights and used that account to run the subscription.  We also gave the service account full permissions on the folder we were writing the .jpg to out on the network.

Thursday, January 28, 2016

Powershell script to automatically start SharePoint workflow on a list of items.

So yesterday I needed to automatically start a 2013 workflow on a list with a lot of items on it.  Here is the Powershell script I wrote to do that.  Hope this helps someone else.

# Run Flawless Execution site workflows automatically
$web = get-spweb -identity "YOURWEBSITEURL"
$list = $web.Lists["YOURLISTNAME"]
$workflow = "YOURWORKFLOWNAME"
$wfm = New-object Microsoft.SharePoint.WorkflowServices.WorkflowServicesManager($web)
$sub = $wfm.GetWorkflowSubscriptionService()
$wf = $sub.EnumerateSubscriptionsByList($list.ID) | Where-Object {$_.Name -eq "$workflow"}
$wis = $wfm.GetWorkflowInstanceService()

$items = $list.Items
foreach($item in $items)
{
$object = New-object 'system.collections.generic.dictionary[string, object]'
$object.Add("WorkflowStart", "StartWorkflow")
$wis.StartWorkFlowOnListItem($wf, $item.ID, $object)
}
$wfm.Dispose()
$web.Dispose()

Thursday, January 21, 2016

Enabling SharePoint 2013 PeoplePicker to retrieve users from multiple domains.


There is already information out on the net about this, but I thought I would try to package this up concisely to help someone (possibly myself) do this in the future.

Has your organization recently acquired another company?
Do you now have multiple domains added to your previously single domain SharePoint Farm?
That has been my motivation for writing this blog post.

We had one domain called "Domain1" and needed to integrate a second domain we will call "Domain2"

Below is the Powershell script for making this happen.

$wa = Get-SPWebApplication -identity "https://sharepoint.company.com"
$key = convertto-securestring "Add_Your_Password_For_The_Search_Account_Here" -AsPlainText -Force
[Microsoft.SharePoint.SPSecurity]::SetApplicationCredentialKey($key)
$adsearchobj = New-Object Microsoft.SharePoint.Administration.SPPeoplePickerSearchActiveDirectoryDomain
$userpassword = Convertto-SecureString "Password_For_UserProfileSynchAccount(Domain1)" -asplaintext -force
$adsearchobj.DomainName = "Domain1"
$adsearchobj.ShortDomainName = "This_Is_Optional"
$adsearchobj.IsForest = $false
$adsearchobj.LoginName = "UserProfileSynchAccountForDomain1"
$adsearchobj.SetPassword($userpassword)
$wa.PeoplePickerSettings.SearchActiveDirectoryDomains.Add($adsearchobj)
$wa.Update()
$wa.PeoplePickerSettings  #This displays current settings for clarity (optional)
$adsearchobj = New-Object Microsoft.SharePoint.Administration.SPPeoplePickerSearchActiveDirectoryDomain
$userpassword = Convertto-SecureString "Password_For_UserProfileSynchAccount(Domain2)" -asplaintext -force
$adsearchobj.DomainName = "Domain2"
$adsearchobj.ShortDomainName = "This_Is_Optional"
$adsearchobj.IsForest = $false
$adsearchobj.LoginName = "UserProfileSynchAccountForDomain2"
$adsearchobj.SetPassword($userpassword)
$wa.PeoplePickerSettings.SearchActiveDirectoryDomains.Add($adsearchobj)
$wa.Update()
$wa.PeoplePickerSettings  #This displays current settings for clarity (optional)

If for some reason you need to back out of this, the below code will remove them one at a time:

$wa = Get-SPWebApplication -identity "https://sharepoint.company.com"
$adsearchobj = $wa.PeoplePickerSettings.SearchActiveDirectoryDomains.Item(1) #zero-based index
$wa.PeoplePickerSettings.SearchActiveDirectoryDomains.Remove($adsearchobj)
$wa.Update()