Windows sharepoint services (WSS 3.0) stsadm not working - powershell

I am new to powershell. I am trying to backup a sharepoint site using a stsadm command but for some reason I keeps on giving me some error.
Here is what I am doing:
PS C:\Users\Administrator> Stsadm –o backup –url >http://server< name:port -filename path\filename to be used for the backup file
Here is the error I am getting:
The term 'stsadm' is not recognized as the name of the cmdlet, function, script file, or operable program. Check the spelling of the name, or path was included, verify that the path is correct and try again,
At line:1 char:7
+ stsadm <<<< stsadm –o backup –url >http://server< name:port -filename path\filename to be used for the backup file
+CategoryInfo : ObjectNotFound: [], CommandNotFoundException
+FullyQualifiedErrorID : CommandNotFoundException

Stsadm is not a powershell script, it is an executable located in C:\Program Files\Common Files\Microsoft Shared\web server extensions\12 or 14 'hive'.
Normally you would refrain from calling stsadm when running powershell as it is effectively deprecated in SharePoint 2010.
You can however change directory to locate the executable and call it if you wish.
Here is a list of stsadm equivalents in powershell.

check this blog post => Backup and Restore SharePoint 2010 Site Collection with PowerShell: http://www.bradleyschacht.com/backup-and-restore-sharepoint-2010-site-collection-with-powershell/
Perhaps, it is what you are looking for

Related

Ubuntu : 'Login-AzureRmAccount' is not recognized as the name of a cmdlet

I have installed Powershell in my Ubuntu machine. When I enter Login-AzureRmAccount into PowerShell, I get error as below:
PS> Login-AzureRmAccount
Login-AzureRmAccount : The term 'Login-AzureRmAccount' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ Login-AzureRmAccount
+ ~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Login-AzureRmAccount:String) [], CommandNotFoundException
When I enter Get-Module -ListAvailable -Name Azure -Refresh, I didn't get any result.
PowerShell version:
powershell -version
powershell v6.0.0-alpha.17
How to solve the above error?
You need to install the Azure PowerShell module first:
#Azure RM NetCore Preview Module Install
powershell Install-Module AzureRM.NetCore.Preview
powershell Import-Module AzureRM.NetCore.Preview
This is my test.
root#shui:/home# powershell
PowerShell
Copyright (C) 2016 Microsoft Corporation. All rights reserved.
PS /home> Login-AzureRmAccount
VERBOSE: To sign in, use a web browser to open the page https://aka.ms/devicelogin and enter the code F2RKUXRNE to authenticate.
For more information please refer to this link.

Import-Module PoshRSJob with Executionpolicy RemoteSigned

I downloaded the PoshRSJob module. When I try to import the module it always throws the following error (translated from German):
PS C:\WINDOWS\system32> ipmo "C:\Program Files\WindowsPowerShell\Modules\PoshRSJob"
ipmo : The File "C:\Program Files\WindowsPowerShell\Modules\PoshRSJob\Scripts\TabExpansion.ps1" could not be loaded. The File "C:\Program
Files\WindowsPowerShell\Modules\PoshRSJob\Scripts\TabExpansion.ps1" is not signed digitally. You can't execute this script on your system. More information: "about_Execution_Policies" unter
"http://go.microsoft.com/fwlink/?LinkID=135170"..
In Zeile:1 Zeichen:1
+ ipmo "C:\Program Files\WindowsPowerShell\Modules\PoshRSJob"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : Sicherheitsfehler: (:) [Import-Module], PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess,Microsoft.PowerShell.Commands.ImportModuleCommand
Our ExecutionPolicy is RemoteSigned
Is there a way to get this module working in a RemoteSigned environment, without Bypassing the Executionpolicy everytime I use the Module in a Script, and without setting the ExecutionPolicy to Unrestricted?
It might be that Windows is treating the files as remote files despite being on your machine locally. Sometimes Windows will know when files have come from the internet (for example if you download through IE or Edge instead of say, Firefox). Behind the scenes, this is storing zone information in an alternate data stream associated with the file, but that can be modified or stripped off.
Right click the PSD1, PS1, PSM1 files inside the module and choose "Properties" and if there's an unblock option, make sure it's unticked.
Alternatively you could run the cmdlet Unblock-File if you have PowerShell 5.1 or greater.

Powershell Runbook - The term 'Get-AzureRMWebAppSlot' is not recognized as the name of a cmdlet

I'm trying to switch connection strings of a website to perform DB Failover, as part of HighAvailability. Please suggest if there are any suitable workarounds for the current requirement.
However, the same script which ran on my local machine is not executing while in the Azure portal as a PowerShell Workflow Runbook.
Powershell Code:
Set-AzureRMWebAppSlot -ResourceGroupName $reourceGroupName -Name $WebSiteName -ConnectionStrings $SecnodaryConnectionStrings -Slot $WebSiteSlot
Error:
Set-AzureRMWebAppSlot : The term 'Set-AzureRMWebAppSlot' is not recognized as the name of a cmdlet, function, script
file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct
and try again.
At AppService-DBConnnectionFailoverSwitch:37 char:37
+
+ CategoryInfo : ObjectNotFound: (Set-AzureRMWebAppSlot:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
This can be done by adding modules to your automation account under Assets
Assets > Modules > Add a Module
Browse Gallery to find AzureRM.Compute

PowerShell 2.0 cannot handle space in $Env:PSModulePath?

It appears that PowerShell 2.0 cannot handle a space in the Env:PSModulePath variable when looking for a module. I have the function in a .psm1 file in a directory under the "\ORGHOST\USRSHR\USERS\lit\My Documents\WindowsPowerShell\Modules" directory.
My organization requires that my Windows document directory be on a network share. This causes the $Env:PSModulePath variable to have "My Documents" as part of the path in the first entry. No, I cannot change the policies set by the organization.
It sounds like I should iterate over the paths in $Env:PSModulePath and find the short (8.3) name for each, then set $Env:PSModulePath using those in my profile script. I would welcome a better suggestion. Any ideas?
If anyone could confirm that this is a problem in PowerShell 2.0, that would be helpful in pushing the organization to upgrade to PowerShell 5.0.
PS 5.0
PS C:\src\powershell> $Env:PSModulePath -split ";"
\\ORGHOST\ORGSHR\Users\lit\My Documents\WindowsPowerShell
C:\Program Files\WindowsPowerShell\Modules
C:\Windows\system32\WindowsPowerShell\v1.0\Modules
PS 2.0
PS C:\Users\lit> $Env:PSModulePath -split ";"
\\ORGHOST\ORGSHR\USERS\lit\My Documents\WindowsPowerShell\Modules
C:\Windows\system32\WindowsPowerShell\v1.0\Modules\
C:\Program Files (x86)\Microsoft SQL Server\110\Tools\PowerShell\Modules\
The term 'Phs-RunBat' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At \\ORGHOST\USRSHR\Users\lit\Scripts\PSAutomation\Phs-RunRemoteBat.ps1:17 char:23
+ [int32]$r = Phs-RunBat <<<< -ComputerName $ComputerName -ScriptPath $ScriptPath -LogFile $LogFile -Verbose
+ CategoryInfo : ObjectNotFound: (Phs-RunBat:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException

New-Object : The term New-Object is not recognized as the name of a cmdlet

I want to configure high trusted app for app dev in SharePoint, and to do so, i need first to insert some commands in the powershell editor like :
$publicCertPath = "C:\Certs\HighTrustSampleCert.cer"
$certificate = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2($publicCertPath)
I am using windows PowerShell on Windows Server 2012 R2 which includes Windows PowerShell 4 that includes by default the new-object cmd-let... I don't understand though, why doesn't my operating system recognize that command ... I don't stop having the following error : New-Object : The term 'New-Object' is not recognized as the name of a cmdlet.
When i open powerShell i get this :
*select :
The term 'Select-Object' is not recognized as the name of a cmdlet,
function, script file, or operable program. Check the spelling of the
name, or if a path was included, verify that the path is correct and
try again. At C:\Program Files\Common Files\Microsoft Shared\Web
Server Extensions\15\CONFIG\POWERSHELL\Registration\SharePoint.ps1:1
char:16
+ $ver = $host | select version
+ ~~~~~~
+ CategoryInfo : ObjectNotFound: (Select-Object:String) [], Comma ndNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException Set-location : The term 'Set-location' is not recognized as the name of a cmdlet,
function, script file, or operable program. Check the spelling of the
name, or if a path was included, verify that the path is correct and
try again At C:\Program Files\Common Files\Microsoft Shared\Web Server
Extensions\15\CONFIG\POWERSHELL\Registration\SharePoint.ps1:4 char:1
+ Set-location $home
+ ~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Set-location:String) [], Comman dNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException*
I thought that was normal until today... does it have any relation with the error? And here is the hole (new-object) exception stack:
New-Object : The term 'New-Object' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling
of the name, or if a path was included, verify that the path is
correct and try again. At line:1 char:16
+ $certificate = New-Object System.Security.Cryptography.X509Certificates.X509Cert ...
+ ~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (New-Object:String) [], CommandN otFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
ps: i want to mention that when i used enter-psSession and worked remotely, the command new-object was recognized but sharepoint commands (like Get-SPAuthenticationRealm) were no more recognized ... And it's like there is a problem related to the operating system.
It appears that your PowerShell installation is corrupted and needs to be repaired. The New-Object cmdlet is exported by the Microsoft.PowerShell.Utility module, which is one of the Core PowerShell modules and should be imported by default on all PowerShell installations.
This can be because the Registry key entry for PSModulesPath is not pre-filled with the default PowerShell Modules path.
$PSModulePath = Get-ItemProperty -Path "HKLM:SYSTEM\CurrentControlSet\Control\Session Manager\Environment" -Name "PSModulePath"
$newPSModulePath = $PSModulePath.PSModulePath + ";C:\Windows\System32\WindowsPowerShell\v1.0\Modules"
Set-ItemProperty -Path "HKLM:SYSTEM\CurrentControlSet\Control\Session Manager\Environment" -Name "PSModulePath" -value $newPSModulePath
Nothing verified here, but I am advancing the hypothesis that Powershell has run into a runtime error that caused it to corrupt its process.