-
-
Notifications
You must be signed in to change notification settings - Fork 706
Expand file tree
/
Copy pathEnableFileSharing.ps1
More file actions
55 lines (43 loc) · 2.54 KB
/
EnableFileSharing.ps1
File metadata and controls
55 lines (43 loc) · 2.54 KB
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 -RunAsAdministrator
Set-StrictMode -Version 3.0
$networkDiscoveryConfigPath = "$([Environment]::GetFolderPath('Windows'))\AtlasDesktop\6. Advanced Configuration\Services\Network Discovery"
$fileSharingConfigPath = "$([Environment]::GetFolderPath('Windows'))\AtlasDesktop\3. General Configuration\File Sharing"
# Enable network items
Enable-NetAdapterBinding -Name "*" -ComponentID ms_msclient, ms_server, ms_lltdio, ms_rspndr | Out-Null
# Enable Network Discovery services and its dependencies
& "$networkDiscoveryConfigPath\Enable Network Discovery Services (default).cmd" /silent
# Enable NetBios over TCP/IP
$interfaces = Get-ChildItem "HKLM:\SYSTEM\CurrentControlSet\Services\NetBT\Parameters\Interfaces" -Recurse | Where-Object { $_.GetValue("NetbiosOptions") -ne $null }
foreach ($interface in $interfaces) {
Set-ItemProperty -Path $interface.PSPath -Name "NetbiosOptions" -Value 2 | Out-Null
}
# Enable NetBIOS service
sc.exe config NetBT start=system | Out-Null
choice /c:yn /n /m "Would you like to change your network profile to 'Private'? [Y/N] "
if ($LASTEXITCODE -eq 1) {
# Set network profile to 'Private Network'
Get-NetConnectionProfile | Set-NetConnectionProfile -NetworkCategory Private
# Disable network discovery firewall rules
Get-NetFirewallRule | Where-Object {
# File and Printer Sharing, Network Discovery
(
($_.Group -eq "@FirewallAPI.dll,-28502" -or $_.Group -eq "@FirewallAPI.dll,-32752") -or
($_.DisplayGroup -eq "File and Printer Sharing" -or $_.DisplayGroup -eq "Network Discovery")
) -and
($_.Profile -like "*Private*")
} | Enable-NetFirewallRule
# Set up network connected devices automatically
New-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\NcdAutoSetup\Private" -Force -EA SilentlyContinue | Out-Null
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\NcdAutoSetup\Private" -Name "AutoSetup" -Value 1 | Out-Null
}
choice /c:yn /n /m "Would you like to add the Network Navigation Pane to the Explorer sidebar? [Y/N] "
if ($LASTEXITCODE -eq 1) {
& "$fileSharingConfigPath\Network Navigation Pane\User Network Navigation Pane choice.cmd" /silent
}
choice /c:yn /n /m "Would you like to restore the 'Give access to' context menu in Explorer? [Y/N] "
if ($LASTEXITCODE -eq 1) {
& "$fileSharingConfigPath\Give Access To Menu\Enable Give Access To Menu.cmd" /silent
}
Write-Host "`nCompleted! " -ForegroundColor Green -NoNewLine
Write-Host "You'll need to restart to apply the changes." -ForegroundColor Yellow
exit