gpt4 book ai didi

powershell - xWebAdministration 未出现在 Get-DscResource (PowerShell) 中

转载 作者:行者123 更新时间:2023-12-02 23:13:27 24 4
gpt4 key购买 nike

这类似于 this question :

我下载了xWebAdminstration .
我在 Windows 中修改了我的环境变量 PSModulePath(我正在 Win 7 上测试/开发)。

在 C:\Program Files\WindowsPowerShell\Modules 中,我有 7 个目录,例如第一个是 MSFT_xiisModule。

我的环境变量 PSModulePath 设置为:
%SystemRoot%\system32\WindowsPowerShell\v1.0\Modules\;C:\Program Files (x86)\Microsoft SQL Server\120\Tools\PowerShell\Modules\

我跑了这个:

Write-Host "`$env:PSModulePath=$($env:PSModulePath)"
Write-Host "`$env:ProgramFiles=$($env:ProgramFiles)"
Write-Host "`$CurrentValue=$CurrentValue"
Write-Host "`$PSVersionTable.PSVersion=$($PSVersionTable.PSVersion)"
Get-Module -ListAvailable
Write-Host "`n`n==== DscResources ====="
Get-DscResource | Select Name, Properties | ft -AutoSize

这是输出(显示模块被找到为模块,但不是 DscResources):
 $env:PSModulePath=C:\Users\neal.walters\Documents\WindowsPowerShell\Modules;C:\Program Files\WindowsPowerS
hell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules\;C:\Program Files (x86)\Microsoft SQL Serv
er\120\Tools\PowerShell\Modules\;c:\Program Files\WindowsPowerShell\Modules\
$env:ProgramFiles=C:\Program Filession=4.0


Directory: C:\Program Files\WindowsPowerShell\Modules


ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Script 0.0 MSFT_xIisModule {Get-TargetResource, Set-TargetResou...
Script 0.0 MSFT_xWebApplication {Get-TargetResource, Set-TargetResou...
Script 0.0 MSFT_xWebAppPool {Get-TargetResource, Set-TargetResou...
Script 0.0 MSFT_xWebConfigKeyValue {Get-TargetResource, Set-TargetResou...
Script 0.0 MSFT_xWebDeploy {Get-TargetResource, Set-TargetResou...
Script 0.0 MSFT_xWebsite {Get-TargetResource, Set-TargetResou...
Script 0.0 MSFT_xWebVirtualDirectory {Get-TargetResource, Set-TargetResou...


Directory: C:\Windows\system32\WindowsPowerShell\v1.0\Modules


ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Manifest 1.0.0.0 AppLocker {Set-AppLockerPolicy, Get-AppLockerP...
Manifest 1.0.0.0 BitsTransfer {Add-BitsFile, Remove-BitsTransfer, ...
Manifest 1.0.0.0 CimCmdlets {Get-CimAssociatedInstance, Get-CimC...
Script 1.0.0.0 ISE {New-IseSnippet, Import-IseSnippet, ...
Manifest 3.0.0.0 Microsoft.PowerShell.Diagnostics {Get-WinEvent, Get-Counter, Import-C...
Manifest 3.0.0.0 Microsoft.PowerShell.Host {Start-Transcript, Stop-Transcript}
Manifest 3.1.0.0 Microsoft.PowerShell.Management {Add-Content, Clear-Content, Clear-I...
Manifest 3.0.0.0 Microsoft.PowerShell.Security {Get-Acl, Set-Acl, Get-PfxCertificat...
Manifest 3.1.0.0 Microsoft.PowerShell.Utility {Format-List, Format-Custom, Format-...
Manifest 3.0.0.0 Microsoft.WSMan.Management {Disable-WSManCredSSP, Enable-WSManC...
Binary 1.0 PSDesiredStateConfiguration {Set-DscLocalConfigurationManager, S...
Script 1.0.0.0 PSDiagnostics {Disable-PSTrace, Disable-PSWSManCom...
Binary 1.1.0.0 PSScheduledJob {New-JobTrigger, Add-JobTrigger, Rem...
Manifest 2.0.0.0 PSWorkflow {New-PSWorkflowExecutionOption, New-...
Manifest 1.0.0.0 PSWorkflowUtility Invoke-AsWorkflow
Manifest 1.0.0.0 TroubleshootingPack {Get-TroubleshootingPack, Invoke-Tro...
Manifest 1.0.0.0 WebAdministration {Start-WebCommitDelay, Stop-WebCommi...


Directory: C:\Program Files (x86)\Microsoft SQL Server\120\Tools\PowerShell\Modules


ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Manifest 1.0 SQLASCMDLETS {Add-RoleMember, Backup-ASDatabase, ...
Manifest 1.0 SQLPS {Backup-SqlDatabase, Add-SqlAvailabi...


Directory: c:\Program Files\WindowsPowerShell\Modules


ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Script 0.0 MSFT_xIisModule {Get-TargetResource, Set-TargetResou...
Script 0.0 MSFT_xWebApplication {Get-TargetResource, Set-TargetResou...
Script 0.0 MSFT_xWebAppPool {Get-TargetResource, Set-TargetResou...
Script 0.0 MSFT_xWebConfigKeyValue {Get-TargetResource, Set-TargetResou...
Script 0.0 MSFT_xWebDeploy {Get-TargetResource, Set-TargetResou...
Script 0.0 MSFT_xWebsite {Get-TargetResource, Set-TargetResou...
Script 0.0 MSFT_xWebVirtualDirectory {Get-TargetResource, Set-TargetResou...


==== DscResources =====



Name Properties
---- ----------
File {DestinationPath, Attributes, Checksum, Contents...}
Archive {Destination, Path, Checksum, DependsOn...}
Environment {Name, DependsOn, Ensure, Path...}
Group {GroupName, Credential, DependsOn, Description...}
Log {Message, DependsOn}
Package {Name, Path, ProductId, Arguments...}
Registry {Key, ValueName, DependsOn, Ensure...}
Script {GetScript, SetScript, TestScript, Credential...}
Service {Name, BuiltInAccount, Credential, DependsOn...}
User {UserName, DependsOn, Description, Disabled...}
WindowsFeature {Name, Credential, DependsOn, Ensure...}
WindowsProcess {Arguments, Path, Credential, DependsOn...}

最佳答案

根据评论,我现在看到问题出在路径结构上。在你的输出中,你有这个:

Directory: c:\Program Files\WindowsPowerShell\Modules


ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Script 0.0 MSFT_xIisModule {Get-TargetResource, Set-TargetResou...
Script 0.0 MSFT_xWebApplication {Get-TargetResource, Set-TargetResou...
Script 0.0 MSFT_xWebAppPool {Get-TargetResource, Set-TargetResou...
Script 0.0 MSFT_xWebConfigKeyValue {Get-TargetResource, Set-TargetResou...
Script 0.0 MSFT_xWebDeploy {Get-TargetResource, Set-TargetResou...
Script 0.0 MSFT_xWebsite {Get-TargetResource, Set-TargetResou...
Script 0.0 MSFT_xWebVirtualDirectory {Get-TargetResource, Set-TargetResou...

您的目录结构应如下所示:
C:\Program Files\WindowsPowerShell\Modules\xWebAdministration\DSCResources\
在那里,这就是 MSFT_x*目录去。这也是为什么版本都被列为 0.0的原因。 .

确保你有模块的父目录( xWebAdministration ),它应该至少包含一个 .psd1 (模块 list )和 DSCResources文件夹,其中是每个资源的文件夹,其中包含 .psm1.mof文件。

http://blogs.msdn.com/b/powershell/archive/2013/12/05/how-to-deploy-and-discover-windows-powershell-desired-state-configuration-resources.aspx为视觉。

关于powershell - xWebAdministration 未出现在 Get-DscResource (PowerShell) 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27989105/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com