首页 > 代码库 > PowerShell Modules
PowerShell Modules
PS SQLSERVER:\> Import-Module AppController
Import-Module : The specified module ‘AppController‘ was not loaded because no valid module file was found in any
module directory.
At line:1 char:1
+ Import-Module AppController
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ResourceUnavailable: (AppController:String) [Import-Module], FileNotFoundException
+ FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand
我有加模块的时候,遇到以下问题,总结一下。
确认是否启用了权限:
Get-ExecutionPolicy
如果是Restricted
执行:
Set-ExecutionPolicy RemoteSigned
Y
再试Import-Module AppController
还是不成,查看是否有module
PS C:\Windows\system32> $env:PSModulePath
PS C:\Users\******> $env:PSModulePath
C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules\;C:\Program Files\Microsoft System Center 2012 R2\Virtual Machine Ma
nager\bin\psModules\;C:\Program Files (x86)\Microsoft SQL Server\110\Tools\PowerShell\Modules\
安装的文件目录不当中。好吧。。。我们把它加上去。
#Save the current value in the $p variable. $p = [Environment]::GetEnvironmentVariable("PSModulePath") #Add the new path to the $p variable. Begin with a semi-colon separator. $p += ";C:\Program Files (x86)\MyCompany\Modules\"
PS C:\Users\****> Get-Module -listAvailable
Directory: C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules
ModuleType Name ExportedCommands
---------- ---- ----------------
Manifest AppLocker {Set-AppLockerPolicy, Get-AppLockerPolicy, Test-AppLockerPolicy, Get-...
Manifest BitsTransfer {Add-BitsFile, Remove-BitsTransfer, Complete-BitsTransfer, Get-BitsTr...
Manifest CimCmdlets {Get-CimAssociatedInstance, Get-CimClass, Get-CimInstance, Get-CimSes...
Script ISE {New-IseSnippet, Import-IseSnippet, Get-IseSnippet}
Manifest Microsoft.PowerShell.Diagnostics {Get-WinEvent, Get-Counter, Import-Counter, Export-Counter...}
Manifest Microsoft.PowerShell.Host {Start-Transcript, Stop-Transcript}
Manifest Microsoft.PowerShell.Management {Add-Content, Clear-Content, Clear-ItemProperty, Join-Path...}
Manifest Microsoft.PowerShell.Security {Get-Acl, Set-Acl, Get-PfxCertificate, Get-Credential...}
Manifest Microsoft.PowerShell.Utility {Format-List, Format-Custom, Format-Table, Format-Wide...}
Manifest Microsoft.WSMan.Management {Disable-WSManCredSSP, Enable-WSManCredSSP, Get-WSManCredSSP, Set-WSM...
Script PSDiagnostics {Disable-PSTrace, Disable-PSWSManCombinedTrace, Disable-WSManTrace, E...
Binary PSScheduledJob {New-JobTrigger, Add-JobTrigger, Remove-JobTrigger, Get-JobTrigger...}
Manifest PSWorkflow {New-PSWorkflowExecutionOption, New-PSWorkflowSession, nwsn}
Manifest PSWorkflowUtility Invoke-AsWorkflow
Manifest TroubleshootingPack {Get-TroubleshootingPack, Invoke-TroubleshootingPack}
Manifest WebAdministration {Start-WebCommitDelay, Stop-WebCommitDelay, Get-WebConfigurationLock,...
Directory: C:\Program Files\Microsoft System Center 2012 R2\Virtual Machine Manager\bin\psModules
ModuleType Name ExportedCommands
---------- ---- ----------------
Binary virtualmachinemanager {Get-SCStorageClusterDisk, Get-SCVMHostFibreChannelHba, New-SCVMHostF...
Binary virtualmachinemanagercore {Use-SCStopVM, Use-SCShutdownVM, Use-SCSaveStateVM, Use-SCDiscardSave...
Directory: C:\Program Files (x86)\Microsoft SQL Server\110\Tools\PowerShell\Modules
ModuleType Name ExportedCommands
---------- ---- ----------------
Manifest SQLASCMDLETS {Add-RoleMember, Backup-ASDatabase, Invoke-ASCmd, Invoke-ProcessCube...}
Manifest SQLPS {Backup-SqlDatabase, Add-SqlAvailabilityDatabase, Disable-SqlAlwaysOn...
Directory: C:\Program Files (x86)\Microsoft System Center 2012 R2\App Controller\PowerShell Modules
ModuleType Name ExportedCommands
---------- ---- ----------------
Binary AppController
已经安装了,但是AppController有了。但是。。。没有Commands.
到AppController安装的路径确认。。。自动安装到下一级目录中了。所以。。。再调整一下。
PS SQLSERVER:\> Import-Module AppController
PS SQLSERVER:\> Get-Module
真的没有问题了。。。:)
本文出自 “luojing” 博客,请务必保留此出处http://luojinghappy.blog.51cto.com/683032/1546570
PowerShell Modules