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
반응형
그리드형(광고전용)
'PowerShell' 카테고리의 다른 글
[POWERSHELL] Disable-WindowsOptionalFeature 명령 : Hyper-V/Hypervisor 비활성화기 (0) | 2022.02.28 |
---|---|
[POWERSHELL] Enable-WindowsOptionalFeature 명령 : Hyper-V/Hypervisor 활성화하기 (0) | 2022.02.28 |
[POWERSHELL] Get-WindowsOptionalFeature 명령 : Hypervisor 활성화 여부 구하기 (0) | 2022.02.28 |
[POWERSHELL] Get-WindowsOptionalFeature 명령 : Hyper-V 활성화 여부 구하기 (0) | 2022.02.28 |
[POWERSHELL] MSBuild와 Advanced Installer를 사용해 설치 파일 만들기 (0) | 2021.11.10 |
[POWERSHELL] Get-WmiObject 명령 : 현재 사용자 계정 구하기 (0) | 2021.06.11 |
[POWERSHELL] Get-Process 명령 : 윈도우즈 화면 잠금 여부 구하기 (0) | 2021.06.11 |
[POWERSHELL] $LASTEXITCODE 환경 변수 : 실행 프로그램 종료 코드 구하기 (0) | 2021.06.09 |
[POWERSHELL] Get-StartApps 명령 : UWP 앱의 패키지 패밀리 이름 구하기 (0) | 2021.05.10 |
[POWERSHELL] Get-Help 명령 : try/catch/finally문 도움말 사용하기 (0) | 2021.04.09 |
댓글을 달아 주세요