小编Luk*_*uke的帖子

测试是否启用了PowerShell远程处理

我一直在寻找,找不到我要找的具体内容,我需要一种方法,我可以测试大约900台机器并判断是否启用了PowerShell远程处理,我想通过下面的脚本我可以验证powershell已安装,但它没有检查它是否可以实际远程管理机器,任何想法?

function Check-PSVersion
{

[CmdletBinding()]
Param (
    [Parameter(Mandatory = $true)]
    $ComputerName
)
if (Test-Path $ComputerName)
{
    $Computers = Get-Content $ComputerName
}
Else
{
    $Computers = $ComputerName
}

Foreach ($Computer in $Computers)
{
    Try
    {
        Write-Host "Checking Computer $Computer"
        $path = "\\$Computer\C$\windows\System32\WindowsPowerShell\v1.0\powershell.exe"
        if (test-path $path) { (ls $path).VersionInfo }
        else
        {
            Write-Host "Powershell isn't installed" -ForegroundColor 'Red'
        }
        Write-Host "Finished Checking Computer $Computer"
    }

    catch { }
}
}
Run Code Online (Sandbox Code Playgroud)

powershell remote-access

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

从Array中选择选项

我正在进行一个侧面项目,并且为了管理更容易,因为几乎所有服务器名称都是15个字符长,我开始寻找RDP管理选项,但没有我喜欢的; 所以我开始编写一个,我只讨论一个问题,如果用户键入的内容不足以进行搜索,我该怎么做才能管理,这样两个服务器就会匹配Query.我想我必须把它放在一个数组中然后让他们选择他们想要的服务器.这是我到目前为止所拥有的

function Connect-RDP
{

param (
    [Parameter(Mandatory = $true)]
    $ComputerName,
    [System.Management.Automation.Credential()]
    $Credential
)

# take each computername and process it individually
$ComputerName | ForEach-Object{
    Try
    {
        $Computer = $_
        $ConnectionDNS = Get-ADComputer -server "DomainController:1234" -ldapfilter "(name=$computer)" -ErrorAction Stop | Select-Object -ExpandProperty DNSHostName
        $ConnectionSearchDNS = Get-ADComputer -server "DomainController:1234" -ldapfilter "(name=*$computer*)" | Select -Exp DNSHostName            
        Write-host $ConnectionDNS
        Write-host $ConnectionSearchDNS
        if ($ConnectionDNS){
        #mstsc.exe /v ($ConnectionDNS) /f
        }Else{
        #mstsc.exe /v ($ConnectionSearchDNS) /f
        }
    }
    catch
    {
        Write-Host "Could not locate computer '$Computer' in …
Run Code Online (Sandbox Code Playgroud)

powershell active-directory powershell-4.0

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