When I enter in PowerShell:
Remove-Alias -Name someAlias
This error shows:
Remove-Alias : The term 'Remove-Alias' 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
+ Remove-Alias -Name someAlias
+ ~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Remove-Alias:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Note: someAlias is already in my alias list, I checked this.
Powershell 5.1 docu of New-Alias:
Notes
To create a new alias, use Set-Alias or New-Alias. To change an alias, use Set-Alias. To delete an alias, use Remove-Item.
So under Powershell 5.x you've to use Remove-Item. In stated in above comment Remove-Alias is only supported in PowerShell 6.
Check this stackoverflow answer how an alias is removed via Remove-Item.
Related
On running Set-MpPreference -DisableScriptScanning 1, I'm getting:
The term 'Set-MpPreference' 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
+ Set-MpPreference -DisableScriptScanning 1
~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Set-MpPreference:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
I've gone through the following threads, but nothing seems to work:
Add-MpPreference is not recognized as a name
Powershell Set-MpPreference -DisableRealtimeMonitoring $true not working
I'm using Powershell v5.1 on Windows 7.
What could the reason be?
Have you tried
Import-Module Defender
I am not sure if the module exists on Windows 7 yet tough...
Use 64bit Powershell:
C:\windows\sysnative\WindowsPowershell\v1.0\powershell.exe
From my question about installing Azure Powershell
I was able to install Azure Powershell 5.1
However when I try to run
Get-Command Get-AzStorageBlobContent
I get
Get-Command : The term 'Get-AzStorageBlobContent' 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-Command Get-AzStorageBlobContent
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Get-AzStorageBlobContent:String) [Get-Command], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException,Microsoft.PowerShell.Commands.GetCommandCommand
I can see the commands listed in the right panel of ISE and I get intellisence help
The link 135170 takes me here
Get-ExecutionPolicy
returns Restricted
You could run set-executionpolicy remotesigned as administrator to fix the issue.
See: https://www.faqforge.com/windows/windows-powershell-running-scripts-is-disabled-on-this-system/
On my Windows 10 I've Powershell 5.0 installed. But when I run the following command on it, I get the above error.
PS command:
Set-AzureKeyVaultKeyAttributes -Name Key2 -VaultName KayVault-abctest -Enable $false
Error
Set-AzureKeyVaultKeyAttributes : The term 'Set-AzureKeyVaultKeyAttributes' 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
+ Set-AzureKeyVaultKeyAttributes -Name Key2 -VaultName KayVault-abctest ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Set-AzureKeyVaultKeyAttributes:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Note
I'm using the topic Create a Key (Portal) in this official Azure lab tutorial.
I believe the name of the cmdlet should be the singular Set-AzureKeyVaultKeyAttribute, rather than the plural Set-AzureKeyVaultKeyAttributes. Note that this is one of the Strongly Encouraged Development Guidelines for Powershell by Microsoft:
To enhance the user experience, the noun that you choose for a cmdlet name should be singular. For example, use the name Get-Process instead of Get-Processes. It is best to follow this rule for all cmdlet names, even when a cmdlet is likely to act upon more than one item.
If you are still seeing the same problem while using a singular name, ensure that the AzureRM.KeyVault module is installed and loaded:
Install-Module AzureRM.KeyVault
Import-Module AzureRM.KeyVault
I need to be able to add antivirus exclusions to MSE on Windows 7 using a powershell (or cmd) script. If I use:
Add-MpPreference -ExclusionPath "C:\Temp"
Add-MpPreference -ExclusionPath "C:\Users\ME\Desktop"
in powershell (which works for Windows 10 Windows Defender) I get this error:
The term 'Add-MpPreference' 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:17
+ Add-MpPreference <<<< -ExclusionPath "C:\Temp"
+ CategoryInfo : ObjectNotFound: (Add-MpPreference:String) [],
CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Any ideas?
I'm trying to run a command that displays several screens of text and I'm trying to use the more command, but it doesn't seem to be working.
When I try to use a command like this:
Get-Help Get-Alias -full | more
I get an error that says this:
more.com : The term 'more.com' 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:14 char:14
+ $input | more.com
+ ~~~~~~~~
+ CategoryInfo : ObjectNotFound: (more.com:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Anyone have any ideas as to why?
Turns out that powershell.exe was not in the path.