Article archive

Create Shared folder

28/04/2013 11:17
Function New-SharedFolder ($FolderPath, $Sharename) {     # Test for existence of folder, if not there then create it     IF (!(Test-Path $FolderPath)) {                    ...

Remove folder recursive

28/04/2013 11:14
#Remove directory recursive, with read-only attributes #Go through all files (not folders) and set read-only attribute to false $void = Get-ChildItem -Path $Destination -Recurse | where { -not $_.PsIsContainer } | foreach { $_.IsReadOnly = $false} #Remove all items then $void = Remove-Item...

Download farm solution

28/04/2013 11:07
If you need to look inside wsp package from farm solution, you have to download it.   function Download-FarmSolution {  [CmdletBinding()]  param(   [Parameter(Mandatory=$True,ValueFromPipeline=$True,ValueFromPipelinebyPropertyName=$True)]   [string]...

Fake web part controls

25/03/2013 13:46
//our target (instance of tested class) has e. g. this.Controls.Add method... var controls = new List<Control>(); Isolate.WhenCalled(() => target.Controls).WillReturnCollectionValuesOf(controls);

Test code in Elevated privileges

25/03/2013 13:34
[TestInitialize] public void TestSetUpSettings() {     target = new CustomAscxUserControlHelper();       //Enable RunWithElevated privileges     var spSecMock =...

Ignore base call method

25/03/2013 13:27
//Ignore Call base.OnLoad and base.OnInit in Unit test //We use base.Onload in CustomAscxUserControl class //Double 'CallBase.CallBase' is used because CustomAscxUserControlHelper inherits from CustomAscxUserControl.   var mock =...

Activate sharepoint features, find if not already activated

16/03/2013 00:45
#Input parameters $webUrl = "https://server/sitecollection/subsite" $SiteUrl= "https://server/sitecollection" $FeatureName = "MyFeatureName" $webAppUrl = (Get-SPSite $SiteUrl).WebApplication.Url.TrimEnd('/'); $IsSandbox = $false #or $true if feature is from sandbox solution   #Activate...

Get features list from wsp solution

13/03/2013 23:29
Get feature list from farm solution $packageName = "sharepointprojectfarm.wsp" $solId = (Get-SPSolution $packageName).Id Get-SPFeature | where {$_.solutionId -eq $solId}|select DisplayName, Scope   Get feature list from sandbox solution ($SiteUrl is needed and -Sandboxed switch) $packageName...

Hash table array

02/03/2013 02:08
#Declare empty array with type to enable adding hashes [array]$arrayOfhashes = @();     Write-Host "" $newItem = @{MyNumber1 = 7800; MyNumber2 = 2} $newItem #add first item $arrayOfhashes += $newItem Write-Host "" $newItem = @{MyNumber1 = 780330; MyNumber2 = 45} $newItem #add next...

Localization in Visual Web Part

14/02/2013 11:32
Localization in Visual Web Part We use label (in ascx file) to be displayed in different languages:   <asp:Label ID="lblEmail" runat="server" Text="<%$Resources:MyResourceFileGlobal, EnterEmailLabelText%>"></asp:Label>     We have more resource files which contains...
Items: 191 - 200 of 384
<< 18 | 19 | 20 | 21 | 22 >>