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

Wednesday, August 20, 2014

Adding Windows PowerShell Cmdlets

 You may all have seen some error like below when running a command on Windows PowerShell. This usually occurs when the command PowerShell snap-in is not added.

The term 'Get-SPWebApplication' is not recognized as the name of a cmdlet, function, script file, or operable program.

Solution:  How to add the required snap-in if not already added from the PowerShell script itself.


# Example to add SharePoint Cmdlets [ SharePoint should be installed on machine ]
if ( (Get-PSSnapin -Name Microsoft.Sharepoint.Powershell -ErrorAction SilentlyContinue) -eq $null )
{
    Add-PsSnapin Microsoft.Sharepoint.Powershell
    Write-Output "`n Snap-in Microsoft.SharePoint.PowerShell added."
}
else
{
    Write-Output "`n Snap-in Microsoft.SharePoint.PowerShell already added."
# Example to add SQL Cmdlets [ SQL management tools should be installed on machine ]
if ( (Get-PSSnapin -Name SqlServerCmdletSnapin100 -ErrorAction SilentlyContinue) -eq $null )
{
    Add-PsSnapin SqlServerCmdletSnapin100
    Write-Output "`n Snap-in SqlServerCmdletSnapin100 added."
}
else
{
    Write-Output "`n Snap-in SqlServerCmdletSnapin100 already added."
}
if ( (Get-PSSnapin -Name SqlServerProviderSnapin100 -ErrorAction SilentlyContinue) -eq $null )
{
    Add-PsSnapin SqlServerProviderSnapin100
    Write-Output "`n Snap-in SqlServerProviderSnapin100."
}
else
{
    Write-Output "`n Snap-in SqlServerProviderSnapin100 already added."
}

AWS Certified Solutions Architect Associate - AWS Introduction - Questions

All the Best !!! Show Result !! Try Again !! ×