-
Notifications
You must be signed in to change notification settings - Fork 1
/
Install-SysinternalsSuiteNano.ps1
55 lines (43 loc) · 2.26 KB
/
Install-SysinternalsSuiteNano.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#requires -Version 5
<#
NAME: Install-SysinternalsSuiteNano.ps1
AUTHOR: Jan Egil Ring (@JanEgilRing)
COMMENT: This script will download the Nano Server version of the Sysinternals Suite and extract it to the specified target directory.
Prerequisites:
You will need administrative credentials for the Nano Server machine
Usage: Customize the variables $NanoServer and $NanoCred in the top of the script, then run line by line.
Notes: -Expand-Archive does not work on Nano Server in Windows Server 2016 Technical Preview 5, but is expected to work in RTM. Due to this issue, the zip-expansion must be performed locally.
-Due to the use of file copy via PS Remoting, PowerShell 5.0 is required.
You have a royalty-free right to use, modify, reproduce, and
distribute this script file in any way you find useful, provided that
you agree that the creator, owner above has no warranty, obligations,
or liability for such use.
VERSION HISTORY:
1.0 05.07.2016 - Initial release
#>
# Variables
$Uri = 'https://download.sysinternals.com/files/SysinternalsSuite-Nano.zip'
$SysinternalsSuiteNanoZip = Join-Path -Path $env:temp -ChildPath SysinternalsSuite-Nano.zip
$SysinternalsSuiteNanoTempDir = Join-Path -Path $env:temp -ChildPath 'SysinternalsSuite-Nano'
$NanoServer = '10.10.1.103'
$NanoCredential = Get-Credential
$TargetDirectory = 'C:\Sysinternals'
# Download Zip-archive
Invoke-WebRequest -Uri $Uri -OutFile $SysinternalsSuiteNanoZip
# Create PowerShell Remoting session, expand Zip-archive and copy to Nano Server via the remoting session
$session = New-PSSession -ComputerName $NanoServer -Credential $NanoCredential
Invoke-Command -Session $session -ScriptBlock {mkdir $using:TargetDirectory}
Expand-Archive -Path $SysinternalsSuiteNanoZip -DestinationPath $SysinternalsSuiteNanoTempDir
Get-ChildItem -Path $SysinternalsSuiteNanoTempDir | Copy-Item -ToSession $session -Destination $TargetDirectory
# Clean up temp files
Remove-Item -Path $SysinternalsSuiteNanoZip
Remove-Item -Path $SysinternalsSuiteNanoTempDir -Recurse
# Test the tools in an interactive session
Enter-PSSession -Session $session
cd\
cls
cd 'C:\Sysinternals'
dir
.\logonsessions64.exe -accepteula
.\PsLoggedon64.exe -accepteula
Exit-PSSession