Enabling internet proxy using powershell


If you are feeling lazy and not intersted in setting up Internet proxy on your server from UI then use the script below to enable and disable.  Nothing special but works.

To Enable the proxy

$ProxyServer = "proxy.com" $ProxyPort = "8080" $Path = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings" $Proxy = $ProxyServer + ":" + $ProxyPort # Enable an explicit proxy Set-ItemProperty -Path $path -Name ProxyEnable -Value 1 #Enable the explicit proxy Set-ItemProperty -Path $path -Name ProxyServer -Value $Proxy #Configure the server settings

To Disable the Proxy

# Disable an explicit proxy
Set-ItemProperty -Path $path -Name ProxyEnable -Value 0 #Disable the explicit proxy

document listing/inventory using powershell


Few weeks back I faced a situation where i have to list all the documents in the site on a given day.  This was only possible either using C# and PowerShell.  I did some research and found some blog where I found a nice script.  I was not able to find the post again so I am putting the script below.  it may help someone.

[System.Reflection.Assembly]::Load("Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c")
[System.Reflection.Assembly]::Load("Microsoft.SharePoint.Portal, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c")
[System.Reflection.Assembly]::Load("Microsoft.SharePoint.Publishing, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c")
[System.Reflection.Assembly]::Load("System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")

function Get-DocInventory([string]$siteUrl) {
$site = New-Object Microsoft.SharePoint.SPSite $siteUrl
foreach ($web in $site.AllWebs) {
    foreach ($list in $web.Lists) {
        if ($list.BaseType -ne “DocumentLibrary” -or $list.Hiddden -eq $false -or $list.title -contains "Template" -or $list.title -contains "Master" -or $list.title -contains "Images" -or $list.title -contains "images" -or $list.title -contains "Template") {
        continue
}
#Add the login in the comments part if you want to filter the documents.
foreach ($item in $list.Items) {
    #$Modified = $item["Modified"]
    #Write-Host $Modified
    #if($Modified -gt $FRiday)
    #{
        $data = @{
        "Site" = $site.Url
        "Web" = $web.Url
        "list" = $list.Title
        "Item ID" = $item.ID
        "Item URL" = $item.Url
        "Item Title" = $item.Title
        "Item Created" = $item["Created"]
        "Item Modified" = $item["Modified"]
        "File Size" = $item.File.Length/1024KB
        }
     #}
New-Object PSObject -Property $data
}
}
$web.Dispose();
}
$site.Dispose()
}

#You can use either a Grid View or csv File.
#Get-DocInventory "http://site.contoso.com" | Out-GridView
Get-DocInventory "http://site.contoso.com" | Export-Csv -NoTypeInformation -Path c:\DocsInventory.csv

creating managed accounts with powershell


A Basic script that allows you to create the Managed Account with PowerShell.

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
$AllAccounts = @("Contoso\Svc_SPFarm","Contoso\Svc_SPSearch","Contoso\svc_SPSvcApp","Contoso\Svc_SPWebApp", "Contoso\Svc_SPUsrProf", "Contoso\Svc_SPSecStor")
foreach($anAccount in $AllAccounts)
{
    $account = New-Object System.Management.Automation.PSCredential $anAccount, (ConvertTo-SecureString “P’@’$’$word” –AsPlainText –Force)
    $managedAccount = New-SPManagedAccount $account
}
Get-SPManagedAccount | Select UserName

Uninstall Workflow Manager and its components


Below are the steps the remove workflow manager completely. I have seen many instances where we had issues during installations.

Removing Workflow Proxy

  1. Central Administration à Application Management à Manage service applications
  2. Select and click delete the “Workflow Service Application Proxy”
  3. Click Remove Data check box and click OK.

Removing Workflow Manager Farm

  1. If you have more than one workflow manager machine. Remove each node from the farm using the
  2. Click Start à All Programs à Workflow Manager configuration à
    Leave the Farm
    à Click confirm button.
  3. Repeat step 2 on every other WFE.
  4. Open SQL Server Management Studio Delete all the following databases (All previous)
    1. 0x_WfManagementDB
    2. 0x_SbGatewayDatabase
    3. 0x_SBContainer01
    4. 0x_WFInstanceManagementDB
    5. 0x_WFResourceManagementDB
    6. 0x_SBManagementDB

Removing Workflow Manager Binaries

  1. Open Control Panel à Uninstall a program à Updates
  2. Uninstall the CU of Service Bus from Updates
  3. Uninstall the CU and updates of Workflow Manager
  4. Click on Programs from left
  5. Now Uninstall Workflow Manager 1.0
  6. Now Uninstall Workflow Manager 1.0 Client
  7. Now Uninstall Service Bus 1.0
  8. Now Uninstall Windows Fabric
  9. Delete the following folders (if Exist).
    1. C:\Program Files\Windows Fabric
    2. C:\Program Files\Service Bus
    3. C:\Program Files\Workflow Manager
  10. Delete the following registry key (if Exist).
    1. HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ServerManager
    2. HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Service Bus
  11. Restart the server
  12. Repeat step 1 to 11 for all workflow manager server.

Uninstall the workflow Manager Client

  1. Open Control Panel à Uninstall a program à Right click on Workflow Manager Client
  2. Click Uninstall.
  3. Repeat this process for servers that has client installed.

How to fix “SharePointDiagnostics” event ID 2


I tried to view health reports and got the error. After some ULS review I was able to resolve it fairly easily.

Event ID 2:Session “SharePointDiagnostics” failed to start with the following error: 0xC0000035

Note: It is allowed to customize the schema of Usage Database.

Central administration à Monitoring à View Health Reports à Click Go

Fix Procedure

  1. Login to SQL Server à Connect to SQL Server Management Studio
  2. Expand Databases
  3. Expand XX_Usage
    à Programmability à Stored Procedures

Find proc_GetSlowestPages stored procedure and commenting out the WITH (READPAST) line.

  1. Comment Out WITH (READPAST) (Just two dashes)

  1. Click Execute. Messages window will show command completed successfully.
  2. Close SQL Server management Studio.
  3. Go back to Health Reports and refresh the page.
  4. Click Go

Issue is now fixed J