-
Notifications
You must be signed in to change notification settings - Fork 0
/
Invoke-MIR_Agent.ps1
35 lines (26 loc) · 976 Bytes
/
Invoke-MIR_Agent.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
<#
.SYNOPSIS
Initiator used to install the MIR Agent.
.REQUIREMENTS
- Requires an account on the remote computer (Hopefully one with permissions)
- Requires C$ or Admin Share
.USAGE
1 - Replace the $computers and $script2run variable to represent your situation
2 - Save your changes
3 - Execute the script
#>
$computers = Get-Content .\computers.txt
$mir_dir = 'C:\users\blue\Desktop\MIR_Agent'
foreach($computer in $computers)
{
# Copies directory to distant workstation
Copy-Item $mir_dir -recurse \\$cpu\c$\.
# Creates variable for WMI process
$Action = [wmiclass] "\\$cpu\ROOT\CIMv2:Win32_Process"
# Creates process creation to invoke the agent install
$Method = $Action.create("powershell /c msiexec /i c:\MIR_Agent\mir_agent.msi /qn ")
# Allows time for the agent to install
sleep 10
# Deletes the script and log file on the distant machine
remove-item \\$cpu\c$\MIR_Agent -Recurse
}