小编Del*_*son的帖子

如何只获得财产价值

我想从计算机名称中检索 IP 地址,但我只想要 IP。

$computer = 'Server1'
$computer = [System.Net.Dns]::GetHostAddresses($computer) | select IPAddressToString
Run Code Online (Sandbox Code Playgroud)

返回@{IPAddressToString=xxxx}。我如何返回“xxxx”

powershell

9
推荐指数
2
解决办法
4万
查看次数

无法让 PSExec 与 Powershell 一起使用

上周我开发了一个脚本来检查是否在指定的机器上启用了 psremoting。本周我开始编写一个可以在指定机器上启用 psremoting 的脚本,但我无法让 psexec 在 powershell 中运行(另外,是的,我知道可以通过组策略启用 psremoting)。这是我的脚本:

$input = Read-Host @"
Select Option
(1)Manually enter computer(s)
(2)Retrieve computer(s) from file

Option
"@

If ($input -eq 1){
    $count = Read-Host "How many computers"
    $Computers = 1..$count
    $b=0;$c=1; ForEach ($Computer in $Computers) {$Computers[$b] = Read-Host "Computer" $c; $b++; $c++}
} ElseIF ($input-eq 2) {
    $Computers = Read-Host "File" 
    $Computers = Get-Content $Computers
} Else {
    write-host "Invalid Option"
    Exit
}

cls
$User = Read-Host "Enter username"
$Pass = Read-Host "Enter …
Run Code Online (Sandbox Code Playgroud)

scripting powershell

5
推荐指数
1
解决办法
2万
查看次数

标签 统计

powershell ×2

scripting ×1