Get-ADDefaultDomainPasswordPolicy does not work on remote server - powershell

Get-ADDefaultDomainPasswordPolicy does not work on remote server below are the details-
steps i followed
enter-pssession -computername server1
Get-ADDefaultDomainPasswordPolicy
The term 'Get-ADDefaultDomainPasswordPolicyPasswordHistoryCount' 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.
+ CategoryInfo : ObjectNotFound: (Get-ADDefaultDo...ordHistoryCount:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException

Related

Why won't it allow me to activate my venv?

I've researched a few things about opening a venv. I've come to realize I need the PowerShell to allow scripts and so I started this session with:
set-executionpolicy remotesigned
Then I went ahead and tried the following, but it is not going through.
P
S C:\Windows\system32\xxxxx> venv/bin/activate
venv/bin/activate : The term 'venv/bin/activate' 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
+ venv/bin/activate
+ ~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (venv/bin/activate:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
PS C:\Windows\system32\xxxxx> source venv/bin/activate
source : The term 'source' 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
+ source venv/bin/activate
+ ~~~~~~
+ CategoryInfo : ObjectNotFound: (source:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Any suggestions as how to move forward?
I had been following a tutorial and they used venv/bin/activate when it should be venv/Scripts/activate

The term 'get-ADComputer' is not recognized as the name of a cmdlet

I'm watching this tutorial (https://www.youtube.com/watch?v=UVUd9_k9C6A&t=1640s) about PowerShell. At 2:57:50, the instructor runs Get-ADComputer. But when I try to run the same command, I get the following error message:
get-ADComputer : The term 'get-ADComputer' 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
+ get-ADComputer
+ ~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (get-ADComputer:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
How can I make it work?

Getting cluster detail of Windows

Is there any other way to get Windows cluster details like cluster & machine info using PowerShell command?
I tried to use Get-Cluster command but it's not working throwing an error.
get-cluster : The term 'get-cluster' 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
+ get-cluster
+ ~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (get-cluster:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException

Install PowerShellGet module

I am working on Windows 2012 R2 and it was running PowerShell version 4.0. I have upgraded to version 5.0.
It seems like that when I do basic commands I get errors, for example,
PS C:\Windows\system32> Install-Module –Name PowerShellGet –Force –Verbose
Install-Module : The 'Install-Module' command was found in the module
'PowerShellGet', but the module could not be loaded. For more
information, run 'Import-Module PowerShellGet'. At line:1 char:1
+ Install-Module –Name PowerShellGet –Force –Verbose
+ ~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Install-Module:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CouldNotAutoloadMatchingModule
Another example:
PS C:\Windows\system32> import-module PowerShellGet
Get-Variable : The term 'Get-Variable' 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\WindowsPowerShell\Modules\PowerShellGet\1.1.3.2\PSModule.psm1:18
char:28
+ $script:IsWindows = (-not (Get-Variable -Name IsWindows -ErrorAction ...
+ ~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Get-Variable:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
I am basically following the installation method for PowerShellGet found here: https://learn.microsoft.com/en-us/powershell/gallery/psget/get_psget_module
I am stuck at the "Install-Module" command in this guide.
Execute the command on your powershell: 'Set-ExecutionPolicy Unrestricted' before executing install-module.
(The restricted mode helps you protect from the the unauthorized scripts)
I know I too late to answer this question. But may help to others.
Try following ,
Set-ExecutionPolicy Unrestricted
Set-PSRepository -Name 'PSGallery' -InstallationPolicy Trusted
and now you can try install-module
This didn't work for me
PS C:\temp> Set-PSRepository -NAME PSGallery -InstallationPolicy Trusted
PackageManagement\Get-PackageProvider : The term 'PackageManagement\Get-PackageProvider' 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\WindowsPowerShell\Modules\PowerShellGet\2.2.5\PSModule.psm1:2934 char:26
... $nugetProvider = PackageManagement\Get-PackageProvider -ErrorA ...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
CategoryInfo : ObjectNotFound: (PackageManagement\Get-PackageProvider:String) [], CommandNotFoundException
FullyQualifiedErrorId : CommandNotFoundException
PackageManagement\Get-PackageProvider : The term 'PackageManagement\Get-PackageProvider' 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\WindowsPowerShell\Modules\PowerShellGet\2.2.5\PSModule.psm1:2948 char:40
... ailableNugetProviders = PackageManagement\Get-PackageProvider -Name $ ...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
CategoryInfo : ObjectNotFound: (PackageManagement\Get-PackageProvider:String) [], CommandNotFoundException
FullyQualifiedErrorId : CommandNotFoundException
PackageManagement\Install-PackageProvider : The term 'PackageManagement\Install-PackageProvider' 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\WindowsPowerShell\Modules\PowerShellGet\2.2.5\PSModule.psm1:3138 char:21
$null = PackageManagement\Install-PackageProvider -Name $ ...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
CategoryInfo : ObjectNotFound: (PackageManageme...PackageProvider:String) [], CommandNotFoundException
FullyQualifiedErrorId : CommandNotFoundException
PackageManagement\Import-PackageProvider : The term 'PackageManagement\Import-PackageProvider' 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\WindowsPowerShell\Modules\PowerShellGet\2.2.5\PSModule.psm1:3144 char:21
$null = PackageManagement\Import-PackageProvider -Name $s ...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
CategoryInfo : ObjectNotFound: (PackageManagement\Import-PackageProvider:String) [], CommandNotFoundException
FullyQualifiedErrorId : CommandNotFoundException
PackageManagement\Get-PackageProvider : The term 'PackageManagement\Get-PackageProvider' 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\WindowsPowerShell\Modules\PowerShellGet\2.2.5\PSModule.psm1:3148 char:30
... $nugetProvider = PackageManagement\Get-PackageProvider -Name $ ...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
CategoryInfo : ObjectNotFound: (PackageManagement\Get-PackageProvider:String) [], CommandNotFoundException
FullyQualifiedErrorId : CommandNotFoundException
Set-PSRepository : NuGet provider is required to interact with NuGet-based repositories. Please ensure that '2.8.5.201' or newer version of NuGet provider is installed.
At line:1 char:1
Set-PSRepository -NAME PSGallery -InstallationPolicy Trusted
+ CategoryInfo : InvalidOperation: (:) [Set-PSRepository], InvalidOperationException
+ FullyQualifiedErrorId : CouldNotInstallNuGetProvider,Set-PSRepository
PS C:\temp>

The term is not recognized as the name of a cmdlet in powershell

We have recently installed SharePoint 2013 on Windows Server 2012 R2.
When I am trying to run Enable-SPSessionStateService -DefaultProvision using Windows PowerShell then below error is occuring. What am I missing here?? Please help.
PS C:\Users\sysuser> Enable-SPSessionStateService -DefaultProvision
Enable-SPSessionStateService : The term 'Enable-SPSessionStateService' 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
+ Enable-SPSessionStateService -DefaultProvision
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Enable-SPSessionStateService:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException