声明:粉丝过300发全部代码。现540行代码,20个函数,超15个API调用。
部分代码:
1.
function net-logoffsession($sessionId){
Add-Type -TypeDefinition @"
using System;
using System.Runtime.InteropServices;
public class WTSAPI32_logoffsession
{
[DllImport("wtsapi32.dll")]
public static extern IntPtr WTSOpenServer([MarshalAs(UnmanagedType.LPStr)] string pServerName);
[DllImport("wtsapi32.dll")]
public static extern void WTSCloseServer(IntPtr hServer);
[DllImport("wtsapi32.dll", SetLastError = true)]
public static extern bool WTSLogoffSession(IntPtr hServer, int SessionId, bool bWait);
}
"@
$serverN