Audience compilation status is in compiling

The audience compilation status is in compiling status on User Profile Synchronization Service for the past 2 weeks.

But the User Profile Service Application – Audience Compilation Job is running successfully on the servers.

The issue got resolved by stopping and starting the Job with the help of PowerShell script.

To get the Audience Compilation Status from Compiling to Idle we executed following steps

1) Open SharePoint Management Shell;

Note: Run as SharePoint Administrator

Execute:

$runjob=[Microsoft.Office.Server.Audience.AudienceJob]::RunAudienceJob($args);

From the output copy the Application ID of the respective User Profile Service Application

For e.g., f4c2b7e2-ce7b-465d-868f-66164af37013

The Audience Compilation is preceded by following executable: AudienceJob.exe and we can force stop or start the compilation using PowerShell.

To stop execute:

Audiencejob.exe f4c2b7e2-ce7b-465d-868f-66164af37013 0

Note: Application ID and 0 or 1 indicates Stop or Start

After we successfully stopped the audience job we then started a full compilation executing following

Audiencejob.exe f4c2b7e2-ce7b-465d-868f-66164af37013 1

Once we execute the above command the audiences will compile successfully.

Advertisements

Disable Enterprise feature on all site collections except one

You can do it with PowerShell.

Add-PSSnapin Microsoft.SharePoint.PowerShell -ea SilentlyContinue

$excludeSite = "http://servername/sites/siteToExclude"

$spWebApp = Get-SPWebApplication

foreach($site in $spWebApp.Sites)
{
if ($site.url -ne $excludeSite)
{
$siteUrl = $site.url
Write-Host "Going into SiteCollection $siteurl"
Disable-SPFeature -identity "SharePoint Server Enterprise Site Collection features"
Write-Host "Disabling feature in SiteCollection $siteurl"
}
}

Or manually, one by one, foollowing the:

In Site Actions –> Site Collection Features of each site collection, you can disable a feature called “SharePoint Server Enterprise Site Collection features” on all site collections except in the one where you want to have these features enabled.

SharePoint Error : The Managed Metadata Service or Connection is currently not available. The Application Pool or Managed Metadata Web Service may not have been started.

This is the best post I have ever read about this issue, so, here is my share!

https://blogs.msdn.microsoft.com/guruketepalli/2013/08/09/sharepoint-error-the-managed-metadata-service-or-connection-is-currently-not-available-the-application-pool-or-managed-metadata-web-service-may-not-have-been-started/

PowerShell: SharePoint – Backup all site collections on the Farm

PowerShell: SharePoint – Backup all site collections of my entire farm, be executable multiple times without overriding old backups, log all script results into a log file, remove backups older than X days, and execute on a daily basis.

Basically, the script version above executes the following logic: -get the weekday and create a backup folder (if it does not exist) in the $backupRoot -loop over all web applications -loop over all sites of the current web application -get a unique backup name for the current site -execute the Backup-SPWeb operation for the given site and store it into a _tmp folder if the variable $clearUpOldFiles = 1, then clear up the existing weekday folder move the backups from _tmp to the weekday folder if $removeFilesOlderThanDays > 0, then check if there are files in the weekday folder that are older than x days. Remove them if you found any. store the log into the “_log” folder that resides in the $backupRoot The script automatically creates all necessary files and folders. Anyway, we have to ensure following if we want to execute successfully this script: the user that executes the backup operation should have read/write permissions on the backup folder the user that executes the backup operation should have enough permissions to execute a Backup-SPWeb operation the script must be executed on a SharePoint server You can download the script directly from the TechNet Script Center http://gallery.technet.microsoft.com/scriptcenter/Backup-all-collections-in-726514cb But we did not cover all requirements! With the script above we are able to cover requirements 1 to 4. You can execute the script manually as many times you want. The backup names are unique and allow you to do this as many times you want. You can even play around with the variables $clearUpOldFiles and $removeFilesOlderThanDays to keep your disk a little bit under control. Nevertheless, we also want to conver requirement 5 and automate the whole story. We only need to create a scheduled task on our Windows Server. The next screens tell you how to do this: go to the server manager of your Windows Server 2008 and go under Configuration –> Task Scheduler press Create Task… on the right side of the screen. You should see screen that follows. I gave to the task the name PowerShell Backup Script, selected Run whether user is logged on or not and ensured that the user that runs the task has enough privileges to write to the backup folder and execute the Backup-SPWeb operation (in my case I selected the SharePoint farm administrator – spowner). I went to the Triggers tab and clicked the button New…. I configured the schedule from Monday to Friday and pressed OK. I went to the Actions tab and clicked the button New…. I copied following execution path: C:WindowsSystem32WindowsPowerShellv1.0powershell.exe -NoLogo -NonInteractive -File “C:ScriptingBackupExecuteBackup.ps1″ into the Program/Script section. Please change the path in bold to your backup destination. Confirm with OK Another window opens. Just confirm. Store the script and we are done. Requirement 5 is covered with the scheduled task. You can still execute the script directly from file system or by executing it directly from the Task Scheduler window

 

PowerShell Code:

sp-backup.ps1

Add-PSSnapin Microsoft.SharePoint.Powershell -ErrorAction SilentlyContinue

# specify here your backup folder

$backupRoot = “C:\ScriptingBackup”

$logPath = Join-Path $backupRoot “_logs”

$tmpPath = Join-Path $backupRoot “_tmp”

# removes all the old backup files on the target folder (valid values: 0 = do not remove; 1 = remove files

$clearUpOldFiles = 0

# specifies the days for the backups that should be persisted

$removeFilesOlderThanDays = -1

# specifies the backupfolder based on the current weekday (Monday… etc.)

$todaysBackupFolder = Join-Path $backupRoot ((Get-Date).DayOfWeek.toString())

# generate all necessary folders if they are missing

if (-not (Test-Path $logPath)) {

New-Item $logPath -type directory

}

if (-not (Test-Path $tmpPath)) {

New-Item $tmpPath -type directory

}

if (-not (Test-Path $todaysBackupFolder)) {

New-Item $todaysBackupFolder -type directory

}

# creates a log file

Start-Transcript -Path (Join-Path $logPath ((Get-Date).ToString(‘yyyyMdd_hhmmss’) + “.log”))

# loop over all web applications (specify filter criteria here if you want to filter them out)

foreach ($webApplication in Get-SPWebApplication) {

Write-Host

Write-Host

Write-Host “Processing $webApplication”

Write-Host “*******************************”

foreach ($site in $webApplication.Sites) {

# we have to replace some characters from the url name

$name = $site.Url.Replace(“http://”, “”).Replace(“https://”, “”).Replace(“/”, “_”).Replace(“.”, “_”);

# replace all special characters from url with underscores

[System.Text.RegularExpressions.Regex]::Replace($name,”[^1-9a-zA-Z_]”,”_”);

# define the backup name

$backupPath = Join-Path $tmpPath ($name + (Get-Date).ToString(‘yyyyMdd_hhmmss’) + “.bak”)

Write-Host “Backing up $site to $backupPath”

Write-Host

# backup the site

Backup-SPSite -Identity $site.Url -Path $backupPath

}

Write-Host “*******************************”

Write-Host “*******************************”

}

Write-Host

Write-Host

# remove the old backup files in the todays folder if specified

if ($clearUpOldFiles -eq 1) {

Write-Host “Cleaning up the folder $todaysBackupFolder”

Remove-Item ($todaysBackupFolder + “*”)

}

# move all backup files from the tmp folder to the target folder

Write-Host “Moving backups from $tmpPath to $todaysBackupFolder”

Move-Item -Path ($tmpPath + “*”) -Destination $todaysBackupFolder

# you can specify an additial parameter that removes filders older than the days you specified

if ($removeFilesOlderThanDays -gt 0) {

Write-Host “Checking removal policy on $todaysBackupFolder”

$toRemove = (Get-Date).AddDays(-$removeFilesOlderThanDays)

$filesToRemove = Get-ChildItem $todaysBackupFolder -Recurse -Include “*.bak” | Where {$_.LastWriteTime -le “$toRemove” }

if ($filesToRemove -ne $null) {

foreach ($fileToRemove in $filesToRemove) {

Write-Host “Removing the file $fileToRemove because it is older than $removeFilesOlderThanDays days”

Remove-Item $fileToRemove

}

}

}

Stop-Transcript

 


					

Unable to Start Service Bus Gateway – Eventid 7031–After .NET 4.6 or 4.7 update

This issue is also noticed when you are running ServiceBus1.1 with Framework 4.6. or 4.7  Recently there is an update released for SB1.1 to work with .Net Framework 4.6. download and install the update https://www.microsoft.com/en-us/download/details.aspx?id=49496 to resolve the issue.

I really recommend you to update your web.config files too, following this post https://guidesharepoint.wordpress.com/2018/12/31/after-installing-net-security-patches-to-address-cve-2018-8421-sharepoint-workflows-stop-working-kb-4457916-4457035-and-others/

Sending email from SharePoint 2013 on-premises via Office 365

Sending email from SharePoint is a fairly basic requirement for almost every installation that we come across, but with the move to hybrid and fully cloud-based email environments configuring this basic functionality becomes a little more complicated than you may expect. Generally in a hybrid or certainly in a cloud-based environment there will be no locally-accessible email server for SharePoint to use.In this post we’ll walk through the steps required to allow an on-premise SharePoint 2013 installation to send email from an Office 365 hosted email account.

Outbound email options

There are a number of options available to use with some requiring more effort than others to configure. These options are detailed in this Technet article (How to Allow a Multi-function Device or Application to Send E-mail through Office 365 Using SMTP). The two most common options we’ve implemented are the “SMTP Relay” and “Client SMTP Submission“, with the latter requiring the least amount of effort from the network and infrastructure teams, and that’s what we’ll use in this scenario.

The Client SMTP Submission method does require us to use a local SMTP server that’s configured for relaying messages, specifically due to SharePoint not supporting authenticated SMTP. To ensure that we don’t have an open relay we’ll limit the machines that are able to connect to and send via our server.

Installing a local SMTP Relay

The first step is to install an IIS SMTP server that will be used for relaying messages from SharePoint. This can be accomplished by using the ‘Add Roles and Features’ wizard, after completion will add a new option “Internet Information Services (6.0)” in the Server Manager ‘Tools’ menu. This is the interface by which we’ll configure the SMTP server, pictured below:

image

Configure SMTP Virtual Server Settings

By default the server listens to all addresses on port 25 which is the default SMTP server port, and Anonymous access is enabled; no changes are required to either of those items for our scenario. However, to ensure that we don’t relay messages from any machine we’ll limit the systems that are able to connect to and send through our server. From the “[SMTP Virtual Server #1] > Properties > Access” tab, click the “Connection” button which brings up the following window:

image

Be sure to specify the IP Address of each of the servers from which messages will be sent. Typically, multiple IP addresses are bound to each SharePoint server to support SSL bindings – be certain to list each of the addresses. In this screenshot, we’ve configured the SMTP Server to allow connections from two of our SharePoint servers.

Next, we’ll also ensure that only our two systems are allowed to relay messages through the SMTP server, which is accomplished by clicking on the “Connection” button on the same “Access” tab of the server properties. Note that we have the same two IP addresses listed, allowing only those two machines to relay:

image

From here, we need to configure the Office 365 mailbox username/password that the SMTP Server will use when sending messages. This is configured in the “Delivery” tab, using the “Outbound Security” button. Be sure to enter valid credentials for your Office 365 user, and if it’s a newly-created user make note that you’ll need to change the initial password on first login. If you don’t do this, mail will not send despite your best efforts!

image

Next we need to tell the server to use TCP port 587 when attempting to connect to Office 365, which is set in the “Outbound Connections” option of the “Delivery” tab:

image

Lastly, we need to specify which server to send mail through, and we do this by clicking the “Advanced” button on the “Delivery” tab. Be sure to specify the smart host as smtp.office365.com and clear the option to “Attempt direct delivery before sending to smart host”: this will ensure that all outbound mail will be sent via Office 365:

image

Configure Outgoing E-Mail Settings in SharePoint

Finally, we need to let SharePoint know about our new SMTP Server, which is done via Central Administration > System Settings > Outbound E-Mail Settings, as pictured below. Note that I’ve blurred out the values to protect the innocent, but you need to be certain to specify the servername, and your Office 365 mailbox user in the From address.

image

At this point, we’re ready to test our configuration and we’ll use PowerShell on the SharePoint server to do so. This way we can be sure that each component in our configuration is working, from the SharePoint settings through to the Office 365 mailbox. Open a SharePoint Management Shell and run the following PowerShell snippet:

$sdo = new-object System.collections.specialized.stringdictionary
$sdo.add("to","mabotega@hotmail.com")
$sdo.add("from","sharepoint@yourdomain.com")
$sdo.add("Subject","Test message from SharePoint")
$web = get-spweb "https://yourwebappURL"
$messagebody = "This is a test message from SharePoint on-prem"
[Microsoft.SharePoint.Utilities.SPUtility]::SendEmail($web,$sdo,$messagebody)

The output of the command will return “True” (and you’ll receive an email message) if it was successful; “False” indicates that something has gone wrong and the message was not delivered.

When things go wrong

In our experience, there are a few items that you’ll want to verify if outbound email is not flowing as expected, including:

  • the SMTP Server service is set to “Manual” start by default; be sure to change this to “Automatic” so that the service starts upon a reboot of your server
  • the Windows Server may require a server certificate in order for TLS to be used; this will generate an error in the Event Log and be evidenced by the SMTP Server Properties “Secure Communication” section of the “Access” tab indicating that no certificate can be found for TLS

Conclusion

E-mail is still a critical communication method in today’s business world, and moving email services to the cloud is more common than ever. We can still send email from an on-premises SharePoint server via Office 365 by setting up a local relay and sending mail from an Office 365 mail-enabled user.

References:

https://social.technet.microsoft.com/Forums/en-US/fb898783-897f-4c4d-960e-7e6b6a2099d8/sending-emails-from-sharepoint-2013-on-premise-to-office-365-sendas-quotthe-curent-userquot?forum=sharepointadmin

User profile service stuck in stopping/starting SharePoint 2010/2013

User profile service stuck in stopping/starting SharePoint 2010

follow below steps to fix stuck service,
1. run this on powershell command or command prompt,
stsadm -o enumservices > c:\services.txt
you will get all services in file and check user profile service tag in it as  following,
<Service>
<Type>Microsoft.Office.Server.Administration.UserProfileService, Microsoft.Office.Server.UserProfiles, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Type>
<Name />
<DisplayName>User Profile Service</DisplayName>
<Status>Unprovisioning</Status>
</Service>
2. run using powershell command for user profile service,
stsadm -o provisionservice -action stop -servicetype “Microsoft.Office.Server.Administration.UserProfileService, Microsoft.Office.Server.UserProfiles, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c” -servicename

– you will get “operation completed successfully” message.
– Restart IIS server.
– You can do same thing for USER profile synchronization service to stop it if it stuck in starting/stopping.
run following for USER PROFILE Synchronization service,
– you can find tag in file,
<Service>
<Type>Microsoft.Office.Server.Administration.ProfileSynchronizationService, Microsoft.Office.Server.UserProfiles, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Type>
<Name>FIMSynchronizationService</Name>
<DisplayName>User Profile Synchronization Service</DisplayName>
<Status>Disabled</Status>
</Service>
– run using powershell command,
stsadm -o provisionservice -action stop -servicetype “Microsoft.Office.Server.Administration.UserProfileService, Microsoft.Office.Server.UserProfiles, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c” -servicename FIMSynchronizationService

– you will get completed successfully message.

– Restart IIS.

References:

http://www.harbar.net/articles/sp2010ups2.aspx#ups14

https://social.technet.microsoft.com/Forums/en-US/87540a6b-36cb-4409-9e81-183be05329ce/user-profile-service-synchronization-service-stuck-in-unprovisioning-state?forum=sharepointadminprevious

https://sharepoint.stackexchange.com/questions/232891/sharepoint-2013-server-search-status-stuck-on-unprovisioning

SharePoint service stuck on stopping/starting

There are times when stopping/starting SharePoint services from Central administration -> System settings -> Manage services page gets stuck.

Tring an IIS reset / Timer job restart on that particular server may solve or may not solve the issue. If not, running PowerShell commands should be able to resolve the issue.

Run Get-SpServiceInstance to list all services running in each server of the farm.
Search for the server name and then find the GUID of the problem service running in that particular server.
Run following command to stop it

Stop-SPServiceInstance -identity .

Run the following to check the status of the service. It should now be Disabled.

Get-SpServiceInstance -identity

If running above command did not change the status, try following commands.

$Var = Get-SpServiceInstance -identity
$Var.Unprovision()

Note: Running above commands sometime may throw following error

An object of the type Microsoft.SharePoint.Administration.SPServiceInstanceJobDefinition named “job-service-instance-baf4a9ed-0fb1-557e-89af-2mar48bccc5f” already exists under the parent Microsoft.SharePoint.Administration.SPTimerService named “SPTimerV4”. Rename your object or delete the existing object.

Run following command to delete timer job and run above mentioned commands again (change the ID according to your scenario).

$Timer = Get-SPTimerJob -Identity “job-service-instance-baf4a9ed-0fb1-557e-89af-2mar48bccc5f”
$Timer.Delete()

If this not work, try this:

#this code WORKS!

stsadm.exe -o deleteconfigurationobject -id <GUID>