Wednesday, January 3, 2018

SPFx: "You don't seem to have a generator with the name “@microsoft\Sharepoint” installed."

  1. install the latest version of node
  2. install the latest version of npm: npm i -g npm@next
  3. run the following in your cmd window or commander window:
    call npm uninstall -g chalk
    call npm uninstall -g loadash
    call npm uninstall -g tar-fs
    call npm uninstall -g update-notifier
    call npm uninstall -g yeoman-generator
    call npm uninstall -g yosay
    call npm uninstall -g yo
    call npm uninstall -g gulp
    call npm uninstall -g @microsoft/generator-sharepoint
    call npm install -g chalk
    call npm install -g loadash
    call npm install -g tar-fs
    call npm install -g update-notifier
    call npm install -g yeoman-generator
    call npm install -g yosay
    call npm install -g yo
    call npm install -g gulp
    call npm install -g @microsoft/generator-sharepoint
  4. Done :)

Tuesday, December 26, 2017

Provider Hosted HighTrust Step by Step

1. Start Services in Central Admin
1. App Management
2. Subscription service
3. UPS

2. Create Web Service Applications in CA
1. UPS
2. App Management

3. Using Power Creae Subscription Proxy service Applications
$account = Get-SPManagedAccount "gdpr/tcadmin"
$appPoolSubSvc = New-SPServiceApplicationPool -Name SettingsServiceAppPool -Account $account
$appSubSvc = New-SPSubscriptionSettingsServiceApplication -ApplicationPool $appPoolSubSvc -Name SPSubscriptionSettingsServiceApplication -DatabaseName "SP-SubscriptionSettingsDB"
$proxySubSvc = New-SPSubscriptionSettingsServiceApplicationProxy -ServiceApplication $appSubSvc

4. Create Self-sign Certificate using Power shell  OR self sign Web hosting Certificate
1. New-SelfSignedCertificate -DnsName "" -CertStoreLocation cert:\LocalMachine\My
2.    --> To create a self-signed test .pfx certificate file

5. Export PFX and CER file form IIS --> Cerficates - save both file at one location.
PFX will use in MVC Web config
CER file will  use in Sharepoint as New-SPTrustedSecurityTokenIssuer (regestrer through powershell command )

6. Register in Sharepoint through Powershell

$certloc = "C:\CERT\certificate.cer"
$certName = "HightTrustDemo"
$issuerId = '11111111-1111-1111-1111-111111111111' # MUST BE UNIQUE
$displayName = "High Trust Demo" # MUST BE UNIQUE

$certificate = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2($certloc)
New-SPTrustedRootAuthority -Name $certName -Certificate $certificate

$realm = Get-SPAuthenticationRealm
$fullIssuerId = $issuerId + "@" + $realm
New-SPTrustedSecurityTokenIssuer -Name $displayName -Certificate $certificate -RegisteredIssuerName $fullIssuerId –IsTrustBroker

7. Add PFX file path , Password and ISsue ID inot MVC Web.config.

8. Generate Client ID and Cliet Secreate from Sharepoint site
URL: http:// SharePoint_website/_layouts/15/appregnew.aspx
Cliet ID : Auto
Secreate : Auto
app Name  : Any thing
Domain :
Redirect URL :

Add Cliet ID and Client Secreate  inot MVC Web.config.

Note: Here Domain, you can add into Host file (Start Menu -> Run -> "Drivers" -> etc/Host --> open wiht notepad)

9. Host your MVC Application into IIS 
1.IIS --> sites --> Create Web site - > set path and host header and port 8443.
2. Change App pool identity to your admin user.

10. in visual Sudio Package app wiht client id and URL

11. Upload *.app file into App catalog.

1. Sharepoint and MVC application Hostheader should not be same.

Friday, December 1, 2017

Disable O365 Sharepoint Online Enable Classic View only

Connect-SPOService –Url –Credential ""
Import-Module Microsoft.Online.Sharepoint.PowerShell

$webUrl = ''
$username = ""
$password = Read-Host -Prompt "Password for $username" -AsSecureString

[Microsoft.SharePoint.Client.ClientContext]$clientContext = New-Object Microsoft.SharePoint.Client.ClientContext($webUrl)
$clientContext.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $password)

# To apply the script to the site collection level, uncomment the next two lines.
$site = $clientContext.Site;
$featureguid = new-object System.Guid "E3540C7D-6BEA-403C-A224-1A12EAFEE4C4"

$site.Features.Add($featureguid, $true, [Microsoft.SharePoint.Client.FeatureDefinitionScope]::None);


Thursday, August 31, 2017

Test Send Mail Power Shell Script

Write-Host "Sending Email"
$smtpServer = ""
$msg = new-object Net.Mail.MailMessage
$smtp = new-object Net.Mail.SmtpClient($smtpServer)
$msg.From = ""
$msg.ReplyTo = ""
$msg.subject = "My Subject"
$msg.body = "This is the email Body."

Friday, July 21, 2017

New SP Trusted Identity Token Issuer

Add-PSSnapin "Microsoft.SharePoint.PowerShell"
#Realm we created in Azure
$realm = "http:///_trust" #your sharepoint application url
#Replace "" and "" with yours here!
$signinurl = ""

$certloc = "E:\SSO\certificate.cer"
# see the attached file srv186CA.cer
$cert = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2($certloc)
New-SPTrustedRootAuthority "DEV Trusted Authority" -Certificate $cert

$NameIdentifier = New-SPClaimTypeMapping -IncomingClaimType "" -IncomingClaimTypeDisplayName "UPN" -LocalClaimType ""
$GivenName = New-SPClaimTypeMapping -IncomingClaimType "" -IncomingClaimTypeDisplayName "Display Name" –LocalClaimType ""
$Email = New-SPClaimTypeMapping -IncomingClaimType "" -IncomingClaimTypeDisplayName "Email" -SameAsIncoming

New-SPTrustedIdentityTokenIssuer -Name "SSO DEV" -Description "TOKEN ISSUER NAME" -realm $realm -ImportTrustCertificate $cert -ClaimsMappings $NameIdentifier,$GivenName,$Email -SignInUrl $signInURL -IdentifierClaim $NameIdentifier.InputClaimType

Thursday, July 20, 2017

Permanently Delete a SharePoint Site Collection.

#To begin, you will need to load the SharePoint Online module to be able to run commands in PowerShell. use your SharePoint administrative site.
Import-Module Microsoft.Online.Sharepoint.PowerShell
$credential = Get-credential
Connect-SPOService -url "" -Credential $credential

Remove-SPOSite -Identity -NoWait

#This command will pause the script for 20 seconds before proceeding.
Start-Sleep -s 20

#This script will permanently delete the SharePoint site collection after it is sent to the SharePoint Site Recycle Bin. You must replace the url  with your Sharepoint Online URL and use your Site Collection Name that is to be permanently deleted for this script to work properly.
Remove-SPODeletedSite -Identity ""
Delete Last x days Sharepoint List item 

Add-PSSnapin Microsoft.SharePoint.PowerShell

$web = Get-SPWeb ""
$list = $web.Lists["EmailNotification"]
$DeleteBeforeDate = [Microsoft.SharePoint.Utilities.SPUtility]::CreateISO8601DateTimeFromSystemDateTime([DateTime]::Now.AddDays(-7))
$caml=' {0} 1 ' -f $DeleteBeforeDate
$query=new-object Microsoft.SharePoint.SPQuery
$col | % {
Write-Host "Deleted ID " $_.Id
Write-Host " Total Item  Deleted" +$col.Count