Error on power shell script,
Import-Module DnsClient
Import-Module : The specified module 'DnsClient' was not loaded because no
valid module file was found in any module directory.
At line:1 char:1
+ Import-Module DnsClient
+ ~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ResourceUnavailable: (DnsClient:String) [Import-Module], FileNotFoundException
+ FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand
Resolve-DnsName
Resolve-DnsName : The term 'Resolve-DnsName' 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
+ Resolve-DnsName
+ ~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Resolve-DnsName:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
PS C:\Users\aquib> $PSVersionTable.PSVersion
Major Minor Build Revision
----- ----- ----- --------
2 0 -1 -1
Resolve-DnsName is one of the commands added in Windows 8/Windows 2012 and later. By design, it is not available on versions of Windows prior to that regardless of which version of PowerShell you use. The command is unavailable on Windows 7 and Windows 2008 R2 and earlier. Most sources I've read say that the underlying WinAPI functions that the command depends upon were added in Windows 8/2012.
I would recommend using [System.Net.Dns]::GetHostEntry($HostnameOrIP) or one of the other non-obsolete static methods in that class. However, that only works for A, AAAA, and PTR records, and there isn't a class in the .Net Framework CLR for generic DNS requests. You'd have to roll your own or use a third-party library like ARSoft.Tools.Net.
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
On a Windows 7 Professional system, it seems not possible to run New-SelfSignedCertificate. I could on a Windows 10 system.
Yes, the shell was started with "Run As Administrator."
PS C:\> new-selfsignedcertificate
new-selfsignedcertificate : The term 'new-selfsignedcertificate' 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
+ new-selfsignedcertificate
+ ~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (new-selfsignedcertificate:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
PS C:\> $PSVersionTable.PSVersion
Major Minor Build Revision
----- ----- ----- --------
5 0 10586 117
As stated in the comments above, this isn't available in Windows 7.
However, if you're looking for something with a similar API and capability, then I have used & can recommend this from Microsoft Script Centre:
https://gallery.technet.microsoft.com/scriptcenter/self-signed-certificate-5920a7c6
Have to install AzureRM module to use azure commands through powershell. You can use below command to do it.
Install-Module -Name AzureRM -AllowClobber
I have my own Powershell module which I use on many servers. I keep it on a network share which is added on some machines to the PSModulePath variable: \\\Server\Scripts\MyModule\.
This allowed me to always use the latest version of my module on each server and I only had to update a single copy.
Now with Powershell 5 there is an issue. If I have this network path in PSModulePath I can't remote onto this machine.
Enter-PSSession : The term 'Measure-Object' is not recognized as the name of a cmdlet, function, script file, or operab
le 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
+ Enter-PSSession Server
+ ~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Measure-Object:String) [Enter-PSSession], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
It's a known error and it could be fixed with enabling second hoop.
Is there a better way to deploy a module and keep it always up-to-date then my approach?
I'd like to use the Message Queueing (MSMQ) Cmdlets Message Queueing (MSMQ) Cmdlets but they all show as unavailable:
PS C:\users\admin\Desktop> Get-MsmqQueue
Get-MsmqQueue : The term 'Get-MsmqQueue' 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-MsmqQueue
+ ~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Get-MsmqQueue:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
I have Windows 8.1 and PowerShell 4 running as administrator
PS C:\users\admin\Desktop> $PSVersionTable.PSVersion
Major Minor Build Revision
----- ----- ----- --------
4 0 -1 -1
According to OP's comment, MSMQ features were not installed :
I just assumed the machine I was on had MSMQ already but it turned out it didn't.
See this question for instructions on how to install them with PowerShell
Here is the error with --> register-AzureProvider
PS C:\> register-AzureProvider -ProviderNamespace Microsoft.DevTestLab
register-AzureProvider : The term 'register-AzureProvider' 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
+ register-AzureProvider -ProviderNamespace Microsoft.DevTestLab
+ ~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (register-AzureProvider:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
If you're using Azure PowerShell Cmdlets version 0.9.8 (or earlier), you will need to do the following first:
Switch-AzureMode AzureResourceManager
Please refer to the documentation on using Using Azure PowerShell with Azure Resource Manager here: https://azure.microsoft.com/en-in/documentation/articles/powershell-azure-resource-manager/.