Monthly Archives: May 2012

Sharepoint Powershell to add a user from a trusted domain to sharepoint

Our sharepoint farm was in Domain A and we wanted to grant rights to a group in Domain B.
It worked fine from the GUI but powershell add-spuser or new-spuser failed – both stating the user ID we were adding was no good.
Specifically this was for Mysites – we had thousands of them so doing it by hand wasn’t an option.

Remove a stuck timer job in SharePoint using Powershell

I recently had a stuck timer job in our sharepoint farm.
It seemed like an easy thing for Powershell, but it turned out to be one step more complicated – I’m not sure why, but here’s the solution I used – thanks to Todd from the Vendor I was working on for providing the fix!

We can use the Cmdlet get-SPTimerJob to see all timerjobs in our sharepoint farm.

If we add a nice little where clause, we can limit the list to a single item:

Normally I’ve been able to assign the results to a variable

ie like this:

Which works.
What didn’t work however was this:

For some reason, I got an error that there was no delete method.
Weird.

So instead:

I’m not sure what the difference is, maybe I even fat fingered it the first time..
but that’s how it got resolved.

Enable Versions on every SharePoint Site with PowerShell (updated with logging)

The Script below will list the version status of every site in your farm.
Note that as the script is below, it only reports, you’ll need to uncomment 3 lines if you want it to make the changes.

It’s a good idea to run the script once or twice before you do that, so you have a log of what settings were.

 

Powershell to enable Versioning for every list and library in a given sharepoint site

Update – A newer version of this script exists here- I’ve left this one here for search results, and because it’s scoped at the web level, whereas the new one is scoped at the IIS level.

This script will enable Versioning for every list and document library in a given sharepoint site.

I’d originally written it to just do document libraries, but changed my mind – things like announcements and calendars are lists, and they are equally important to protect. Same with some of the default libraries like “Site Assets”

Note that if the script sees that versioning is already enabled, it tells you – so no harm running the script more than once.