Tag Info

New answers tagged

0

On first deploy using visual studio, the solution feature is also activated. This step is not executed on deployment via powershell.. even in your script. Activate the feature through script or UI and it should work fine.


0

Ideally, if the Url of the sub site is correct. The PS command $sWeb = Get-SPWeb $SourceWebURL should work. Since it isn't working for you, there is another way you can try it: $siteCollectionUrl = 'http://servername/sites/sitename' $site = Get-SPSite $siteCollectionUrl $web = $site.OpenWeb('subsitename')


1

I don't recall the reason, but I had also faced this problem and the solution was to first create SPSite object and use it in get-spweb. $siteURL = "http://server:80/sites/sitename" $webURL = "/subsitename" $site = get-spsite $siteURL get-spweb -site $site $webURL


0

I knew for a while that answer would reside in calling Import-SPWeb from a different console context since the SharePoint command seems to call console.writeline ("str"); I have learned a lot about creating powershell runspaces & Invoke commands. Ultimately I found that a solution in spawning new powershell process which cleans itself up. Step 1: ...


1

The first way is kind of manual way where you are creating the SPWeb object and then disabling the property of the object. The second way is the correct method. It uses the Out of the box PowerShell CMDLet to disable the feature. If you are planning to disable for all then use foreach($webApp in Get-SPWebApplication) { foreach ($SPsite in ...


0

Try adding this in CSS of your masterpage or as part of editor web part custom css to see if it helps. <style type="text/css"> .ms-webpartPage-root { border-spacing: 0px !important; } .ms-webpartzone-cell { margin: 0px !important; }


0

Problem for my case was profile.ps1 for PowerShell. Answer is to comment all code (Admin rights, Add-PSSnapin etc.) in profile.ps1. Open Windows PowerShell ISE like always (Run as Admin) Run this if (!(test-path $profile.AllUsersAllHosts)) {new-item -type file -path $profile.AllUsersAllHosts –force} powershell_ise $profile.AllUsersAllHosts if profile.ps1 ...


0

There are two types of links. Relative Absolute Relative URL will work without any issue. But Absolute URL are hard to fix. It can appear in anywhere on the Site. I am not sure using PowerShell it can be fixed in all the places. On one of my recent migration project we did it manually by dividing it among our team members (changing it to relative)


0

ErrorAction allows you to specify a custom error action for each cmdlet or each line of code in your script. In the code seen here, the first line of code informs you of an error if it occurs while retrieving the content of the c:\fso\computers.txt file. If an error occurs, after informing you of the problem, the script continues to the next line. The ...


0

The following are the supported FieldTypes you can use Note DateTime Currency Number Choice Person or Group Calculated Example [string[][]]$fields = ("MyChoices","Choice","Left;Right"),("MyNumber","Number","")


0

New-SPWeb creates a subsite, if you want to create Apple under /sites it is a site collection and you have to use New-SPSite New-SPSite https://yoursite.com/sites/apple -OwnerAlias "DOMAIN\user" -Name Apple Check this link for more information on this Powershell command


1

Similar to the above answer but check if the web application time zone and the server time zone are identical, you could refer this article: Time zone issue


0

The problem in my environment was that that it was because of default zone settings of the web application Take a look of this link:The content has expired


1

SPWeb is a subsite inside a site collection. But you want to create a new root site under a managed path, so have to create a new site collection. With a new site collection, a new SPWeb is also generated as the root site. New-SPSite https://example.com/sites/apple -Name "Apple" -Template "STS#0" PS: New-SPWeb is used, if you want to create another ...


0

Size is not directly available. You should iterate through the SPWeb folders and then add up the file size. $webs = Get-SpWebApplication <insert web app URL here> | Get-SPSite -Limit All | Get-SPWeb -Limit All $results = @() foreach($web in $webs) { $size = GetWebSize($web) $result = New-Object System.Object $result | ...


0

Its because you haven't loaded the $list. Use below code and try $web = $clientContext.Web $list = $web.Lists.GetByTitle("Pages") $clientContext.Load($list) $clientContext.ExecuteQuery() $count = $list.ItemCount $newline = [environment]::newline Write-Host -NoNewline "Deleting listitems from Pages" -foregroundcolor black -backgroundcolor yellow $continue ...


0

try the script in the following link: How to Add WebPart to the Publishing Page using PowerShell in SharePoint 2013 - See more at: http://www.sharepointpals.com/post/How-to-Add-WebPart-to-the-Publishing-Page-using-PowerShell-in-SharePoint-2013#sthash.Qb34PJms.dpuf I hope it helps


0

There is no App Pool associated with the State Services, because it is just a container(maintains state for user sessions and many out of the box features). What I am thinking, whoever (I mean services application or web application) want to use this state services, use his own app pool & sharepoint services for it. There is no App Pool associated with ...


2

Instead of using foreach loop, try performing operation using a for loop. for($node=0;$node -lt $nodeC.Count;$node++){ $nodeVal = $nodeC[$node]; $nodeC.Delete($nodeVal);}


1

http://www.dmcinfo.com/Latest-Thinking/Blog/articleType/ArticleView/articleId/8471/Using-SPWebProcessBatchData-to-Update-Document-Library-Properties.aspx Summary: When running ProcessBatchUpdate on a document library you need to pass the server relative url of the file in each item. Use SPListItem.File.ServerRelativeUrl or ...


1

Assuming you have same destination fields with same type as in source list following PowerShell will solve the purpose... try { # OUTPUT TO SCREEN THE CURRENT SPWEB. write-host "Working on Web: "$_.Title -ForegroundColor Green $numDaysToExpire = $ExpireDays $expireDate = Get-Date $expireDate = $expireDate.AddDays(-$numDaysToExpire) ...


0

How to delete Enterprise Keywords using SharePoint CSOM in PowerShell Clear-Keywords.ps1 PS script: param ( [string]$UserName, [string]$Password, [string]$Url ) [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client") [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client.Runtime") ...


1

To allow the web service to upload larger files try to increase the value of maxRequestLength (system.web/httpRuntime) as well as the value of maxAllowedContentLength (system.webServer/security/requestFiltering/requestLimits) See this forum thread.


0

Yes you can do this using powersehll. Refer this article. For sending email use powershell command Send-MailMessage. More on this from here


0

Generally yes, but you will need to write a PS script doing all the described work for you instead of just a single command. You can get more useful info about Backup-SPSite command here. Also you can find good examples of usage of Backup-SP* commands here.


1

Eric Soo found the answer: setting the ObjectID field. But a bit of powershell code might come in handy for people not knowing where to look for that specific field. $list = $rootWeb.Lists |? {$_.RootFolder.ServerRelativeUrl -eq "/Relationships List"} $items = $list.Items foreach($item in $items) { $item["ObjectID"] = "$($rootWeb.Url), /" ...


1

you need to cycle one way or the other, by this i mean iterate either through ad groups or through sharepoint groups and compare the two.... im lazy and created a console application that explains how todo it. When i get the chance i will post PS code! .cs code is checking against AD and looping sharepoint as i think you could have many AD groups and less ...


2

You can use below snippet Get-SPUser -Web http://server/sites/yoursite | Where { $_.IsDomainGroup } AD group is treated as a special user. So this can be find using the filter IsDomainGroup Update $SPWebApp = Get-SPWebApplication https://*******.com/ foreach ($SPSite in $SPWebApp.Sites) { write-host -foregroundcolor green "Working on Site ...


0

Here is a snippet which you can use, the web part XML file should be placed in a local folder. # Add PowerShell Snapin $snapin = Get-PSSnapin | Where-Object {$_.Name -eq 'Microsoft.SharePoint.Powershell'} if ($snapin -eq $null) { Add-PSSnapin "Microsoft.SharePoint.Powershell" } # Get the Site URL $SiteUrl = "https://MySiteCollectionURL/" # Get ...


0

Reputation class from Microsoft.Office.Server.ReputationModel namespace (CSOM assembly Microsoft.SharePoint.Client.UserProfiles.dll) contains the following method: public static ClientResult<int> SetLike(ClientRuntimeContext context, string listID, int itemID, bool like) The following example demonstrates how to set Like for a List Item using ...


1

That will only work with the local instance or machines joined to same domain. You can look at remoting but you need to configure it to work with non-domain machine. For instance - If you want run from Dev.com and connect to Prod.com you have to set your SharePoint servers on Prod to trust the machine in the Dev domain to run PowerShell command. To add ...


0

See the solution implemented in C# here. You should either use the Reputation class: Reputation.SetLike(listID, itemID, true); or via updating the item’s LikesCount and LikedBy fields: SPFieldUserValueCollection likedBy = new SPFieldUserValueCollection(web, item["LikedBy"].ToString()); SPUser user = web.EnsureUser("YOURDOMAIN\\USERNAME"); ...


1

Try to use RunWithElevatedPrivileges.... if(-not(Get-PSSnapin | Where { $_.Name -eq "Microsoft.SharePoint.PowerShell"})) { Add-PSSnapin Microsoft.SharePoint.PowerShell; } [Microsoft.SharePoint.SPSecurity]::RunWithElevatedPrivileges( { $web = get-spweb http://xyz/ $list = $web.lists | where {$_.title -eq “Employee”} #Write-host “List ...


0

I don't think you need all of that. Try just: catch { "Error: " + $_.Exception.Message | out-file $logfile -append }


1

Make sure you are opening "SharePoint Management Shell" and not "Windows PowerShell" Make sure the account you logged in has enough permission. Also try opening the SharePoint Management Shell by selection Run as administrator context menu. First try below snippet and check you are able to see output on the screen write-host "Starting Script" ...


1

You remove Microsoft CRM Visitors, and rmvd\timc becomes RoleAssignments[0]. So in the next iteration you remove RoleAssignments[1] which is now rmvd\amyw. RoleAssignments[2] is now empty. You need to either always remove the last entry, or do this using a while loop.


0

Try this $ct = @() $spWebApp = $Site.WebApplication foreach($allSites in $spWebApp.Sites) { foreach($Web in $allSites.AllWebs) { foreach($list in $Web.Lists) { if($list.BaseTemplate -eq "DocumentLibrary" -and $list.AllowContentTypes -eq $true) { if(-not ($systemlibs -Contains ...


0

Use this: Get-SPWeb http://intranet.site.net | Select -ExpandProperty Lists | Where { $_.BaseTemplate -eq "DocumentLibrary" -and $_.Hidden -eq $false -and $_.ContentTypesEnabled -eq $true}| Select Title, RootFolder Also note that there is no property called Urlin SPList. Use RootFolder of SPList along with SPWeb.Url to get the Url of the list.


0

The code below works but I am getting so many noises like pages, image, documents, site assets and many other libraries with it. I need to add more code to exclude built in libraries. I end up re-doing the code and the following code is good enough for my requirements. #For Output file generation $OutputFN = "Libraries.csv" #delete the file, If already ...


0

Try this Get-SPWeb http://intranet.site.net | Select -ExpandProperty Lists | Where { $_.BaseTemplate -eq "SPDocumentLibrary" -and -not $_.Hidden -and $_["ContentTypesEnabled"] -eq "True" } | Select Title, Url


3

The ClientRuntimeContext.Load method has the following signature: public void Load<T>( T clientObject, params Expression<Func<T, Object>>[] retrievals ) where T : ClientObject How to invoke ClientRuntimeContext.Load<T> method in PowerShell Invoke-LoadMethod function demonstrates how to specify retrievals parameter for ...


1

Read this article http://jeffreypaarhuis.com/2012/06/07/scripting-sharepoint-online-with-powershell-using-client-object-model/ In one of the comments, a user has mentioned about retrieving property HasUniqueRoleAssignments and how he resolved it. The idea is to create a dll which uses csom to get the property. And then use it via PowerShell. public void ...


1

You could exclude these users like this: $users = get-msoluser -all | Where-Object { (-not $_.isLicensed) -and ($_.DisplayName -notmatch "svc")} References about_Comparison_Operators


3

Try this $SyncUser = get-msoluser -all | Where-Object { $_.isLicensed -ne "TRUE" } Foreach ($a in $SyncUser){ if ($a.DisplayName.Contains("svc") -eq $False) { add-content -value ($a.Userprincipalname) -path $Logfile } }



Top 50 recent answers are included