Get-LastBootUpTime.ps1 :

param(
string$COMPUTERNAME
)
$wmi = Get-WmiObject -Class Win32_OperatingSystem -ComputerName $COMPUTERNAME
$LocalDateTimeMinusLastBootUpTime = $wmi.ConvertToDateTime($wmi.LocalDateTime) – $wmi.ConvertToDateTime($wmi.LastBootUpTime)
[System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") | Out-Null
[System.Windows.Forms.MessageBox]::Show($wmi.ConvertToDateTime($wmi.LastBootUpTime))


And add this to RemoteSoftware.xml

<Software>
<ProgramPath>C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe</ProgramPath>
<Options>-ExecutionPolicy Bypass -file "the file location\Get-LastBootUpTime.ps1" {computerName}</Options>
<Default>false</Default>
<Name>BootUpTime</Name>
</Software>

Connect-Mstsc.ps1:

param (
Parameter(Mandatory=$true,Position=0)
Alias("CN")
string[]$ComputerName,
Parameter(Mandatory=$true,Position=1)
Alias("U")
string$User,
Parameter(Mandatory=$true,Position=2)
Alias("P")
string$Password,
Parameter(Mandatory=$false,Position=3)
Alias("A")
switch$Admin
)
begin {
[string]$MstscArguments = ''
switch ($true) {
{$Admin} {$MstscArguments += '/admin'}
}
}
process {
foreach ($Computer in $ComputerName) {
$ProcessInfo = New-Object System.Diagnostics.ProcessStartInfo
$Process = New-Object System.Diagnostics.Process

$ProcessInfo.FileName = "$($env:SystemRoot)\system32\cmdkey.exe"
$ProcessInfo.Arguments = "/generic:TERMSRV/$Computer /user:$User /pass:$Password"
$Process.StartInfo = $ProcessInfo
$Process.Start()

$ProcessInfo.FileName = "$($env:SystemRoot)\system32\mstsc.exe"
$ProcessInfo.Arguments = "$MstscArguments /v $Computer"
$Process.StartInfo = $ProcessInfo
$Process.Start()
}
}

And add this to RemoteSoftware.xml

<Software>
<ProgramPath>C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe</ProgramPath>
<Options>-ExecutionPolicy Bypass -file "The file location\Connect-Mstsc.ps1" -ComputerName {computerName} -User {userName} -Password {password}</Options>
<Default>false</Default>
<Name>RDP</Name>
</Software>

Last edited Apr 26, 2015 at 1:09 PM by itamartz, version 4