첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
728x90
반응형
728x170

▶ 원격 로그온 상태 구하기 예제

GetRemoteLogonStatus 'localhost'

GetRemoteLogonStatus '127.0.0.1'

 

728x90

 

▶ 원격 로그온 상태 구하기

function GetRemoteLogonStatus($computer = 'localhost')
{
    if(Test-Connection $computer -Count 2 -Quiet)
    {
        try
        {
            $user = $null

            $user = Get-WmiObject -Class win32_computersystem -ComputerName $computer | select -ExpandProperty username -ErrorAction Stop
        }
        catch
        {
            "Not logged on";

            return
        }

        try
        {
            if((Get-Process logonui -ComputerName $computer -ErrorAction Stop) -and ($user))
            {
                "Workstation locked by $user"
            }
        }
        catch
        {
            if($user)
            {
                "$user logged on"
            }
        }
    }
    else
    {
        "$computer Offline"
    }
}
728x90
반응형
그리드형(광고전용)
Posted by icodebroker

댓글을 달아 주세요