Showing posts with label PowerShell. Show all posts
Showing posts with label PowerShell. Show all posts

Wednesday, 6 September 2017

Update site logo on all SharePoint sites in a site collection

Update site logo on all SharePoint sites in a site collection

Hi there - I used the script below to update the site logo on a bunch of SharePoint Site Collections today - hope it proves useful to you

 ## Set up the variables

$spWeb = Get-SPWeb $SiteURL
$logopath = "C:\Scripts\Logo\logo_SPsites.png"

Write-Host("- Uploading and updating site logo") -ForegroundColor Magenta


## Creating instance of Folder
$spFolder = $spWeb.GetFolder("SiteAssets")

## Getting the file on Disk that we want to upload
$file = Get-Item $logopath

## Uploading the file the the Site Assets library

$null = 
$spFolder.Files.Add("SiteAssets/logo_SPsites.png",$file.OpenRead(),$false)
   

## Set the logo on all webs in the site:      

$sitelogo="$siteurl/$spFolder/ERIS_logo_SPsites.png"

$Site=$SiteURL

$Sites=new-object Microsoft.SharePoint.SPSite($Site)

foreach($web in $Sites.Allwebs) {

$web.SiteLogoUrl=$sitelogo

$web.Update()}


$Sites.Dispose()

###########################################################################

That's it!

Wednesday, 15 March 2017

Powershell script: bulk add users to SharePoint group

Note - You may need to check the Claims prefix



Here's the PowerShell:

<# Instructions:

Create a Users.txt in this format (all in one column):

    i:0#.w|domain\aparnis
    i:0#.w|domain\candlandan
    i:0#.w|domain\stivj001
    i:0#.w|domain\attaj001
    i:0#.w|domain\marchorovitz
    etc

Populate the variables

#>

## Adding snap-in
Add-PSSnapin "Microsoft.SharePoint.PowerShell"

# Variables

$group = "External Readers"
$loc = "C:\scripts"        
$Users = Get-Content "$loc\Users.txt"        
$web = Get-SPWeb -identity $siteCollUrl

# code

foreach ($User in $Users) {
    $web.EnsureUser($User)        
    Set-SPUser -Identity $User -Web $siteCollUrl -Group $group         
}

# Dispose the web object


$Web.Dispose()

Tuesday, 14 February 2017

Translating SharePoint Audit log reports:

Translating Site ID and PrincipleID

I produced a Audit report for Security events and though I can see that some security events occurred on the relevant dates I couldn't find a way to translate the Site ID and the Principle ID in the Site ID and Event Data columns. 

It can be done! Enter PowerShell!!!!


Audit Log exported to Excel and downloaded: It just looks horrible



Translate the siteID:

$site = get-spsite -limit all
$site | select ID, url | ft -AutoSize | out-file C:\Scripts\siteID.txt

Then I did a find in the .txt file to match the site ID with the URL

e.g.



Translate the PrincipleID:
  
$site = new-object Microsoft.SharePoint.SPSite("http://SPWebApplication");  
$ServiceContext = [Microsoft.SharePoint.SPServiceContext]::GetContext($site);  
$ProfileManager = new-object Microsoft.Office.Server.UserProfiles.UserProfileManager($ServiceContext)    
$AllProfiles = $ProfileManager.GetEnumerator() 

$AllProfiles | select displayname,recordID | ft -autosize | out-file c:\scripts\profiles.txt

Then do a Find on the Principle ID and you will get the Display name mapping:




Translating groupid and userid

/_layouts/userdisp.aspx?id=


E.G

I’ve run a custom security report and the results show 5 permissions edits:


The Event Data column shows the user affected in group\user format











To find:

/_layouts/userdisp.aspx?id=218

/_layouts/userdisp.aspx?id=283

/_layouts/userdisp.aspx?id=8

Etc

This shows you either the user's information or the group's members depending on the entered id 

So: 
/_layouts/userdisp.aspx?id=218 - shows a user id
/_layouts/userdisp.aspx?id=8 - shows group membership


Note: The ids are unique within site collections only. So ...?id=42 within site collection A might be a different user or group in site collection B.


That's all folks - Thanks for visiting!

Sunday, 11 December 2016

SharePoint Solution checker

Here is a nice little script I use to audit Solutions:


#This loads the SharePoint assemblies


asnp *sh* -ea 0

#Start solution audit

$allsolutions = (get-spsolution).SolutionID

foreach
($solution in $allsolutions)
{
$filteredfeaturelist = get-SPFeature | where {$_.SolutionID -eq "$solution"}
write-host -background Blue Name = $filteredfeaturelist.DisplayName
write-host -BackgroundColor Green -ForegroundColor Black Version = $filteredfeaturelist.ReceiverAssembly
write-host ""

}

Saturday, 23 March 2013

PowerShell script - CRM version number and rollup updates


################
#     This script queries the local server registry to obtain the CRM version number and installs rollup updates depending on the returned version number
#  
#     Jonathan read and Jason Hough
#
#     14.02.13
#################

###Logging###


$scriptname = $MyInvocation.MyCommand.Name
$scriptpath = $MyInvocation.MyCommand.Path

$transcriptFile = "C:\Users\mgr1137107\Documents\Powershell_$scriptname.log"

Start-Transcript $transcriptFile -append -force

Write-Output "Starting Script: $scriptpath"


###Variables###

$path ="Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSCRM"
$name = "CRM_Server_Version"


###Trapping###


$p=Get-ItemProperty $path
if(!$p){


    'CRM is not deployed on this server'


}else{


    ' CRM is deployed on this server - the script will now continue'


}

###Functions###

FUNCTION DEPLOYMENT1

#Deploys rollup 6 then rollup 11

{ write-host "Deploying rollups 6 and 11"      }

FUNCTION DEPLOYMENT2

#Deploys rollup 11

{   write-host "Deploying rollup 11"     }


###VersionNumber###



    $key = Get-Item -LiteralPath $path -ErrorAction SilentlyContinue
    if ($key) {
        $key.GetValue($name, $null)
    }


# $VN = $key.GetValue($name, $null)
Write-host "The version number is "$key.GetValue($name, $null)

###CORE LOGIC###

if (

($Version -eq "5.0.9688.1045") -or ($Version -eq "5.0.9688.1157") -or ($Version -eq "5.0.9688.1244") -or ($Version -eq "5.0.9688.1450") -or ($Version -eq

"5.0.9688.1533")

 )

{DEPLOYMENT1}

else


{DEPLOYMENT2}


stop-transcript




Monday, 30 April 2012

Change the location of the IIS log files - IIS7

At some point - you'll need to stop IIS logging to the C:\

Open the SharePoint 2010 Management Shell
 The IIS snap-in first needs to be loaded using Import-Module WebAdministration

 Here is the command to change the log file directory for the default web site:

Set-ItemProperty 'IIS:\Sites\Default Web Site' -name logFile.directory -value 'D:\IISLogs'
Now, open up the IIS Manager console, expand Sites, click on the site you changed the log directory for and double click on Logging under the IIS section. You should see the new directory location under Log File

 You will need to perform this on each server in the farm.

SharePoint Information Architecture Diagram

Here is the template I use for Information Architecture designs. It's built using Mindjet and I flesh the nodes out with the low level d...