Does PowerShell cmdlet Get-WindowsFeature only work on Windows Server? - windows

New to Powershell here.
I'm running a system with Windows-10.
Is the PowerShell command Get-WindowsFeature only available on Windows Server?
When I run this command:
Get-WindowsFeature
I get the following error:
Get-WindowsFeature : The term 'Get-WindowsFeature' 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-WindowsFeature
+ CategoryInfo : ObjectNotFound: (Get-WindowsFeature:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Here is my current PowerShell version information:
Name Value
---- ----- PSVersion 5.1.19041.2364
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.19041.2364
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Thanks

Related

Cannot use cd on Windows Powershell. Path not found

Cannot use cd: file not found
When I run
cd C:\Users\zoua2\Downloads\pwa-ecommerce-demo-payment-request-api.zip\pwa-ecommerce-demo-payment-request-api
on powershell. It outputs
cd : Cannot find path 'C:\Users\zoua2\Downloads\pwa-ecommerce-demo-payment-request-api.zip\pwa-ecommerce-demo-payment-request-api' because it does not exist.
At line:1 char:1
+ cd C:\Users\zoua2\Downloads\pwa-ecommerce-demo-payment-request-api.zi ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (C:\Users\zoua2\...ent-request-api:String) [Set-Location], ItemNotFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.SetLocationCommand
Device data:
Operating system: Windows 10 64 bit
PSVersionTable Data:
Name Value
---- -----
PSVersion 5.1.18362.752
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.18362.752
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
You're getting that error because C:\Users\zoua2\Downloads\pwa-ecommerce-demo-payment-request-api.zip\pwa-ecommerce-demo-payment-request-api is not a valid file path.
Windows programmatically unpacks the archive metadata and allows you to seemlessly "browse" the contents in Explorer, but the entries in the archive don't actually exists as files in the underlying file system - not until you unpack the zip file.
If you don't want to unpack the entire archive to disk, do like Explorer does and inspect the archive programmatically before extract anything!

Powershell : $host.version output different between script and shell

Why the output of $host.version is different if we start it from a script called with ".\script.ps1" and if we execute the command un the shell ?
from shell :
PS C:\Users\user\Desktop> $PSVersiontable
Name Value
--- -----
PSVersion 5.1.14409.1005
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.14409.1005
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
from script :
PS C:\Users\user\Desktop>.\check.ps1
System.Collections.Hashtable
Key : PSVersion
Value : 5.1.14409.1005
Name : PSVersion
Key : PSEdition
Value : Desktop
Name : PSEdition
Key : PSCompatibleVersions
Value : {1.0, 2.0, 3.0, 4.0...}
Name : PSCompatibleVersions
[...]
Thanks
Because they're different hosts.. Console, ISE, etc. are all different hosts.
If you're referring to your PowerShell version, they aren't different, even in your own question.

gradle version manager tool for windows like pik for ruby

Like pik which provides the facility to switch between ruby versions on the fly from command prompt, is there any tool which provides the same kind of behavior for gradle, so that i can switch to gradle version I'm using based on need.
I googled it, but couldn't find proper solution. So posting here.
Below error I'm getting when use sdkman windows version:
PS C:\Users\user> Import-Module posh-gvm
This command is not available in offline mode.
At C:\Users\user\Documents\WindowsPowerShell\Modules\posh-gvm\Utils.ps1:294 char:14
+ throw <<<< 'This command is not available in offline mode.'
+ CategoryInfo : OperationStopped: (This command is...n offline mode.:String) [], RuntimeException
+ FullyQualifiedErrorId : This command is not available in offline mode.
Import-Module : The specified module 'posh-gvm' was not loaded because no valid module file was found in any module dir
ectory.
At line:1 char:14
+ Import-Module <<<< posh-gvm
+ CategoryInfo : ResourceUnavailable: (posh-gvm:String) [Import-Module], FileNotFoundException
+ FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand
Yes, there's such tool. It's called sdkman. You can easily switch between versions of gradle, groovy and other available frameworks, languages.

Error while loading Oracle.DataAccess.dll

I am getting error while executing below command in powershell.
[Reflection.Assembly]::LoadFile("C:\Oracle\Oracle11gClientR1\ODP.NET\bin\2.x\Oracle.DataAccess.dll")
This is the error.
Exception calling "LoadFile" with "1" argument(s): " is not a valid Win32 application. (Exception from HRESULT: 0x80070
0C1)"
At line:1 char:32
+ [Reflection.Assembly]::LoadFile <<<< ("C:\Oracle\Oracle11gClientR1\ODP.NET\bin\2.x\Oracle.DataAccess.dll")
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException
Can anybody advise me what am i doing wrong?
I checked this path (
C:\Oracle\Oracle11gClientR1\ODP.NET\bin\2.x\Oracle.DataAccess.dll
) and it is correct.
Update:
Powershell version is 2.
And i tried these as well
Add-Type -AssemblyName "c:\Oracle\Oracle11gClientR1\ODP.NET\bin\2.x\Oracle.DataAccess.dll"
Add-Type "c:\Oracle\Oracle11gClientR1\ODP.NET\bin\2.x\Oracle.DataAccess.dll"
But no luck.
In that case, most probably you are running PowerShell version 2.0 with .NET Framework version 4.0 which is incompatible. Try using a compatible .NET Framework version. To check
Powershell version run the command
$PSVersionTable.psversion
To check .NET framework version installed run below command and check the 2nd line 3rd column data
gci "hklm:\SOFTWARE\Microsoft\NET Framework Setup\NDP"
EDIT:
Few more suggestions:
Try using LoadFrom() instead like
[Reflection.Assembly]::Assembly.LoadFrom("c:\Oracle\Oracle11gClientR1\ODP.NET\bin\2.x\Oracle.DataAccess.dll");
(OR) Try using Add-Type instead like
Add-Type -AssemblyName "c:\Oracle\Oracle11gClientR1\ODP.NET\bin\2.x\Oracle.DataAccess.dll"
Also, make sure that you are not trying load 32-bit Oracle.DataAccess.dll from 64-bit Windows Powershell. I mean they both should be compaitible.

Remote PowerShell : Error 307

On a Widnows 7 PC, I have an error 307 when I run the Invoke-Command or Enter-PSSession in PowerShell. I have the two computers in the trusted zone. When I run the same command on a Windows 8.1 or Windows Server 2012 R2, I don't have the error and the command works perfectly. The target runs Windows Server 2012 R2.
They both run PowerShell v4.0 (for Widnows 7, I upgraded according to MS : https://www.microsoft.com/en-us/download/details.aspx?id=40855).
For Windows 7 :
PS C:\> $PSVersionTable
Name Value
---- -----
PSVersion 4.0
WSManStackVersion 3.0
SerializationVersion 1.1.0.1
CLRVersion 4.0.30319.18444
BuildVersion 6.3.9600.16406
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0}
PSRemotingProtocolVersion 2.2
PS C:\> Enter-PSSession -ComputerName 127.0.0.1
[...]HTTP error 307[...]
+ Enter-PSSession -ComputerName 127.0.0.1
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument : (127.0.0.1:String) [Enter-PSSession], PSRemotingTransportException
+ FullyQualifiedErrorId : CreateRemoteRunspaceFailed
For Windows 8.1 or Windows Server 2012 R2 :
PS C:\> $PSVersionTable
Name Value
---- -----
PSVersion 4.0
WSManStackVersion 3.0
SerializationVersion 1.1.0.1
CLRVersion 4.0.30319.34014
BuildVersion 6.3.9600.17400
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0}
PSRemotingProtocolVersion 2.2
PS C:\> Enter-PSSession -ComputerName 127.0.0.1
[127.0.0.1]: PS C:>
Moreover, when I test the connexion with Test-WSMan, I get a HTTP error 12152. And the two machines ping the other.
Have you an idea for a possible solution ?
ps : the exact English message when run Invoke-Command :
[xxxxx] Connecting to remote server srvpwdev01 failed with the following error message : <f:WSManFault xmlns:f="http://schemas.microsoft.com/wbem/wsman/1/wsmanfault" Code="2150859023" Machine="xxxxx"><f:Message></f:Message></f:WSManFault> For more information, see the about_Remote_Troubleshooting Help topic.
+ CategoryInfo : OpenError: (srvpwdev01:String) [], PSRemotingTransportException
+ FullyQualifiedErrorId : -2144108273,PSSessionStateBroken
I have the number 307 in a French Windows.

Resources