Initial commit
This commit is contained in:
102
scripts/powershell/setup-network-share.ps1
Normal file
102
scripts/powershell/setup-network-share.ps1
Normal file
@@ -0,0 +1,102 @@
|
||||
[Console]::OutputEncoding = [Text.Encoding]::UTF8
|
||||
$ErrorActionPreference = 'Continue'
|
||||
|
||||
Write-Host "[*] Setting up network share access"
|
||||
|
||||
# Network share path
|
||||
$sharePath = "\\192.168.88.231\rd"
|
||||
$shortcutPath = "C:\Users\User\Desktop\Network Share (RD).lnk"
|
||||
|
||||
Write-Host "[*] Testing connection to network share"
|
||||
Write-Host " Target: $sharePath"
|
||||
|
||||
# Test network connectivity
|
||||
try {
|
||||
$testConnection = Test-NetConnection -ComputerName "192.168.88.231" -Port 445 -WarningAction SilentlyContinue
|
||||
if ($testConnection.TcpTestSucceeded) {
|
||||
Write-Host "[OK] Network connection successful (Port 445 accessible)"
|
||||
} else {
|
||||
Write-Host "[!] Warning: Port 445 not accessible - SMB might be blocked"
|
||||
}
|
||||
} catch {
|
||||
Write-Host "[!] Network test failed: $($_.Exception.Message)"
|
||||
}
|
||||
|
||||
Write-Host "[*] Creating desktop shortcut to network share"
|
||||
|
||||
# Create shortcut using WScript.Shell
|
||||
try {
|
||||
$WshShell = New-Object -comObject WScript.Shell
|
||||
$Shortcut = $WshShell.CreateShortcut($shortcutPath)
|
||||
$Shortcut.TargetPath = $sharePath
|
||||
$Shortcut.WorkingDirectory = $sharePath
|
||||
$Shortcut.IconLocation = "shell32.dll,4" # Folder icon
|
||||
$Shortcut.Description = "Network Share - RD"
|
||||
$Shortcut.Save()
|
||||
|
||||
Write-Host "[OK] Desktop shortcut created: Network Share (RD).lnk"
|
||||
} catch {
|
||||
Write-Host "[!] Failed to create shortcut: $($_.Exception.Message)"
|
||||
}
|
||||
|
||||
Write-Host "[*] Testing share access"
|
||||
|
||||
# Test if we can access the share
|
||||
try {
|
||||
if (Test-Path $sharePath) {
|
||||
Write-Host "[OK] Network share is accessible"
|
||||
|
||||
# Try to list contents
|
||||
$items = Get-ChildItem $sharePath -ErrorAction SilentlyContinue | Select-Object -First 5
|
||||
if ($items) {
|
||||
Write-Host " Found $($items.Count) items in share"
|
||||
} else {
|
||||
Write-Host " Share appears empty or no read permission"
|
||||
}
|
||||
} else {
|
||||
Write-Host "[!] Network share not accessible"
|
||||
Write-Host " Possible issues:"
|
||||
Write-Host " - Share doesn't exist"
|
||||
Write-Host " - No network access"
|
||||
Write-Host " - Authentication required"
|
||||
Write-Host " - SMB protocol blocked"
|
||||
}
|
||||
} catch {
|
||||
Write-Host "[!] Error accessing share: $($_.Exception.Message)"
|
||||
}
|
||||
|
||||
Write-Host "[*] Checking if drive mapping is needed"
|
||||
|
||||
# Check if we should map as network drive
|
||||
$availableDrives = Get-WmiObject -Class Win32_LogicalDisk | Where-Object {$_.DriveType -eq 3} | Select-Object -ExpandProperty DeviceID
|
||||
$networkDrives = Get-WmiObject -Class Win32_LogicalDisk | Where-Object {$_.DriveType -eq 4} | Select-Object -ExpandProperty DeviceID
|
||||
|
||||
Write-Host " Current network drives: $($networkDrives -join ', ')"
|
||||
|
||||
# Suggest mapping to Z: drive if not already used
|
||||
if ("Z:" -notin ($availableDrives + $networkDrives)) {
|
||||
Write-Host "[*] Attempting to map network drive Z:"
|
||||
try {
|
||||
& net use Z: $sharePath
|
||||
Write-Host "[OK] Network drive Z: mapped successfully"
|
||||
} catch {
|
||||
Write-Host "[!] Drive mapping failed - may require credentials"
|
||||
Write-Host " Manual mapping: net use Z: $sharePath /user:username"
|
||||
}
|
||||
} else {
|
||||
Write-Host " Z: drive already in use"
|
||||
}
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "[OK] Network share setup complete!"
|
||||
Write-Host ""
|
||||
Write-Host "Access methods:"
|
||||
Write-Host "1. Double-click 'Network Share (RD).lnk' on desktop"
|
||||
Write-Host "2. Type '$sharePath' in File Explorer address bar"
|
||||
if ("Z:" -notin $availableDrives) {
|
||||
Write-Host "3. Use Z: drive if mapping was successful"
|
||||
}
|
||||
Write-Host ""
|
||||
Write-Host "If access is denied, you may need to:"
|
||||
Write-Host "- Right-click shortcut > Run as administrator"
|
||||
Write-Host "- Provide network credentials when prompted"
|
||||
Reference in New Issue
Block a user