-
Notifications
You must be signed in to change notification settings - Fork 1
/
FixOtherItems-Hastable.ps1
58 lines (44 loc) · 1.9 KB
/
FixOtherItems-Hastable.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
56
57
58
#Run def updates
."C:\Program Files\Windows Defender\MpCmdRun.exe" -removedefinitions -dynamicsignatures
."C:\Program Files\Windows Defender\MpCmdRun.exe" -SignatureUpdate
#Create a Hashtable
$listofprograms = @{
#value order: TestPath, TargetApp, Program Location, $description
"Key1" = @("C:\Program Files (x86)\Scomis\Hosted Applications\HostedAppsConnector.exe", "C:\Program Files (x86)\Scomis\Hosted Applications\BootStrap.exe", "$env:PROGRAMDATA\Microsoft\Windows\Start Menu\Programs\Scomis\Scomis Hosted Applications.lnk", "Scomis Hosted Applications")
"Key2" = @("Value2a", "Value2b", "Value2c", "Value2d")
"Key3" = @("Value3a", "Value3b", "Value3c", "Value3d")
"Key4" = @("Value4a", "Value4b", "Value4c", "Value4d")
}
#Loop though hash table
$listofprograms.GetEnumerator() | ForEach-Object {
$key = $_.Key
$TestPathVar = $_.Value[0]
$target = $_.Value[1]
$shortcut_path = $_.Value[2]
$description = $_.Value[3]
#Write-Host "$TestPathVar,$target,$shortcut_path,$description"
#Scomis
if ((Test-Path -Path "$TestPathVar")) {
#Start Menu
$workingdirectory = (Get-ChildItem $target).DirectoryName
$WshShell = New-Object -ComObject WScript.Shell
$Shortcut = $WshShell.CreateShortcut($shortcut_path)
$Shortcut.TargetPath = $target
$Shortcut.Description = $description
$shortcut.WorkingDirectory = $workingdirectory
$Shortcut.Save()
Start-Sleep -Seconds 1
#Desktop
$workingdirectory = (Get-ChildItem $target).DirectoryName
$WshShell = New-Object -ComObject WScript.Shell
$Shortcut = $WshShell.CreateShortcut($shortcut_path)
$Shortcut.TargetPath = $target
$Shortcut.Description = $description
$shortcut.WorkingDirectory = $workingdirectory
$Shortcut.Save()
Start-Sleep -Seconds 1
}
else {
Write-Host "No Scomis"
}
}