【问题标题】:PowerShell DSC secedit.exe SecEdit.exe Case Sensitive?PowerShell DSC secedit.exe SecEdit.exe 区分大小写?
【发布时间】:2019-05-13 00:07:33
【问题描述】:

我是 PowerShell 的新手,正在尝试编写第一个 DSC 脚本。

Install-Module -Name SecurityPolicyDsc

但是,当我运行配置时,我得到...

VERBOSE: [COMPUTER]: LCM:  [ Start  Test     ]  [[AccountPolicy]AccountPolicies]
The term 'secedit.exe' 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.
    + CategoryInfo          : ObjectNotFound: (secedit.exe:) [], CimException
    + FullyQualifiedErrorId : CommandNotFoundException
    + PSComputerName        : localhost

在我的 Windows 10 系统上,secedit.exe 似乎实际上被称为 C:\WINDOWS\system32\SecEdit.exe。 C:\ 是 NTFS。

知道如何在调用 secedit.exe 时使 Powershell 不区分大小写吗?

【问题讨论】:

  • PowerShell 在调用可执行文件时不区分大小写。我会检查您的 Path 环境变量是否正确。

标签: powershell dsc


【解决方案1】:

事实证明,C:\Windows\System32 并没有像 Bill 建议的那样在 PATH 上。我使用 Advanced System Settings -> Environment Variables 将 PATH 设置为包含 C:\Windows\System32。然后我重新启动了 PC,以便服务也接受了更改,现在它可以工作了。非常感谢。

PS C:\WINDOWS\system32> Start-DscConfiguration -Path c:\dsc -Wait -Force -Verbose
VERBOSE: Perform operation 'Invoke CimMethod' with following parameters, ''methodName' = SendConfigurationApply,'className' = MSFT_DSCLocalConfigurationManager,'namespace
Name' = root/Microsoft/Windows/DesiredStateConfiguration'.
VERBOSE: An LCM method call arrived from computer COMPUTER with user sid S-1-5-21-1762681051-3184050464-2174412407-1001.
VERBOSE: [COMPUTER]: LCM:  [ Start  Set      ]
VERBOSE: [COMPUTER]: LCM:  [ Start  Resource ]  [[AccountPolicy]AccountPolicies]
VERBOSE: [COMPUTER]: LCM:  [ Start  Test     ]  [[AccountPolicy]AccountPolicies]
VERBOSE: [COMPUTER]:                            [[AccountPolicy]AccountPolicies] Testing AccountPolicy: Enforce_password_history
VERBOSE: [COMPUTER]:                            [[AccountPolicy]AccountPolicies] Current policy: 15 Desired policy: 15
VERBOSE: [COMPUTER]:                            [[AccountPolicy]AccountPolicies] Testing AccountPolicy: Maximum_Password_Age
VERBOSE: [COMPUTER]:                            [[AccountPolicy]AccountPolicies] Current policy: 42 Desired policy: 42
VERBOSE: [COMPUTER]:                            [[AccountPolicy]AccountPolicies] Testing AccountPolicy: Minimum_Password_Age
VERBOSE: [COMPUTER]:                            [[AccountPolicy]AccountPolicies] Current policy: 1 COMPUTERpolicy: 1
VERBOSE: [COMPUTER]:                            [[AccountPolicy]AccountPolicies] Testing AccountPolicy: Minimum_Password_Length
VERBOSE: [COMPUTER]:                            [[AccountPolicy]AccountPolicies] Current policy: COMPUTERDesired policy: 12
VERBOSE: [COMPUTER]:                            [[AccountPolicy]AccountPolicies] Testing AccountPolicy: Password_must_meet_complexity_requirements
VERBOSE: [COMPUTER]:                            [[AccountPolicy]AccountPolicies] Current policy: Enabled Desired policy: Enabled
VERBOSE: [COMPUTER]:                            [[AccountPolicy]AccountPolicies] Testing AccountPolicy: Store_passwords_using_reversible_encryption
VERBOSE: [COMPUTER]:                            [[AccountPolicy]AccountPolicies] Current policy: Disabled Desired policy: Disabled
VERBOSE: [COMPUTER]: LCM:  [ End    Test     ]  [[AccountPolicy]AccountPolicies]  in 0.4340 seconds.
VERBOSE: [COMPUTER]: LCM:  [ Skip   Set      ]  [[AccountPolicy]AccountPolicies]
VERBOSE: [COMPUTER]: LCM:  [ End    Resource ]  [[AccountPolicy]AccountPolicies]
VERBOSE: [COMPUTER]: LCM:  [ End    Set      ]
VERBOSE: [COMPUTER]: LCM:  [ End    Set      ]    in  2.5460 seconds.
VERBOSE: Operation 'Invoke CimMethod' complete.
VERBOSE: Time taken for configuration job to complete is 2.791 seconds

【讨论】:

    猜你喜欢
    • 2012-12-01
    • 2013-03-06
    • 2020-02-18
    • 1970-01-01
    • 2022-06-18
    • 1970-01-01
    • 2020-03-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多