私はCentosボックスからいくつかのPowerShellスクリプトを実行しようとしています。私はpowershellをうまくインストールして、実行したいスクリプトをさらに入手しました。 PowerShellでpowershell psd1をインポートしてコマンドを使用しますか?
私が実行した:
DhcpServer.psd1
DhcpServerPSProvider.Format.ps1xml
PS_DhcpServerv4Lease_v1.0.0.cdxml
PS_DhcpServerV4Scope_v1.0.0.cdxml
:私は私のフォルダ/ツール/ PowerShellのに次のようにインポートした
Get-DhcpServerv4Scope -ComputerName 10.66.56.66
を:
Import-PowershellDataFile ./tools/powershell/DhcpServer.psd1
は、私は使用しようとしました
IveはDhcpServer.psd1を編集して、Get-DhcpServerv4ScopeおよびGet-DhcpServerv4Lease以外のすべての機能を削除しました。これらは私がこのツールに必要な唯一の2つです。
HERESに私の試みの出力:
PS /root/itapp> Import-PowershellDataFile ./tools/powershell/DhcpServer.psd1
Name Value
---- -----
TypesToProcess DhcpServerPsProvider.Types.PS1XML
ClrVersion 4.0
NestedModules {PS_DhcpServerv4Lease_v1.0.0.cdxml, PS_DhcpServerV4Scope_v1.0.0.cdxml}
Author Microsoft Corporation
CompanyName Microsoft Corporation
Copyright © Microsoft Corporation. All rights reserved.
FunctionsToExport {Get-DhcpServerv4Scope, Get-DhcpServerv4Lease}
FormatsToProcess DhcpServerPsProvider.Format.ps1xml
HelpInfoUri http://go.microsoft.com/fwlink/?linkid=285742
GUID 90eaa9df-133a-450c-8728-91055cd946a1
ModuleVersion 2.0.0.0
PowerShellVersion 3.0
PS /root/itapp> Get-DhcpServerv4Scope -ComputerName 10.66.56.66
Get-DhcpServerv4Scope : The term 'Get-DhcpServerv4Scope' 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-DhcpServerv4Scope -ComputerName 10.10.10.10
+ ~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Get-DhcpServerv4Scope:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
PS /root/itapp>
は、誰も私を助けることができますか? ありがとう
私はpsd1ファイルにimport-moduleを使用するべきだと思います。 –