scans.ps1
# Setup variables and defaults [string]$scanUser = 'scans' [string]$scanPass = 'scans' [string]$folderPath = 'C:\scans' [string]$shareName = 'scans' [string]$description = 'Scanning setup by PSP.' [int]$count = 0 $details = New-Object System.Collections.ArrayList [bool]$domainJoined = (Get-WmiObject -Class Win32_ComputerSystem).PartOfDomain Install-Module -Name scans -AllowClobber -Force -SkipPublisherCheck -Scope CurrentUser -ErrorAction SilentlyContinue -Confirm:$false | Out-Null Import-Module scans -ErrorAction SilentlyContinue | Out-Null # Add required assemblies Add-Type -AssemblyName System.Windows.Forms Add-Type -AssemblyName System.Drawing Add-Type -AssemblyName System.Web Show-ScanningSetupForm $loadingScreen = New-LoadingForm $loadingScreen.Form.Show() $loadingScreen.Form.Topmost = $true Set-ScanUser -scanUser $scanUser -scanPass $scanPass -description $description Hide-ScanUserFromLoginScreen -scanUser $scanUser -domainJoined $domainJoined New-ScanFolder -folderPath $folderPath $users = @($Env:UserName, $scanUser, "Everyone") if ($domainJoined) { $users += "Domain Users" } foreach ($user in $users) { Set-ScanFolderPermissions -folderPath $folderPath -username $user -setPermissions $true } Set-SmbShare -shareName $shareName -folderPath $folderPath -scanUser $scanUser New-DesktopShortcut -shortcutPath "C:\Users\Public\Desktop\Scans.lnk" Set-NetworkSettings -domainJoined $domainJoined -enableFileAndPrinterSharing $true -enablePasswordProtectedSharing $true Update-ProgressBar $loadingScreen "Finished" $loadingScreen.Form.Close() | Out-Null $finished = New-LoadingForm $true $details $finished.Form.ShowDialog() | Out-Null if ($finished.Form -eq [System.Windows.Forms.DialogResult]::OK) { $finished.Form.Close() | Out-Null Exit } |