如果我知道服务名称并拥有足够的权限,如何在 PowerShell 中将 Windows 服务设置为自动重启?
我使用的是 PowerShell 1.0,操作系统是 Windows Server 2003。
这是一种预期的行为:
PS C:\> Test-Path -Path C:\MyFolder\ -IsValid -PathType Container
True
PS C:\>
Run Code Online (Sandbox Code Playgroud)
但是,这似乎是不正确的:
PS C:\> Test-Path -Path C:\MyFolder\ -IsValid -PathType Leaf
True
PS C:\>
Run Code Online (Sandbox Code Playgroud)
根据官方文件:
"Leaf.不包含其他元素的元素,例如文件."
https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/test-path?view=powershell-6
这是一个错误还是我错过了什么?
注意:目标是测试尚不存在的文件的语法.并且IsValid参数应该这样做.