wbMSPmodule.psm1


<#PSScriptInfo
 
.VERSION 1.4
 
.GUID 0508c4ca-2a89-49a6-b869-0839c8541ee8
 
.AUTHOR WadeBach22
 
.COMPANYNAME
 
.COPYRIGHT
 
.TAGS
 
.LICENSEURI
 
.PROJECTURI
 
.ICONURI
 
.EXTERNALMODULEDEPENDENCIES
 
.REQUIREDSCRIPTS
 
.EXTERNALSCRIPTDEPENDENCIES
 
.RELEASENOTES
 
 
#>


<#
 
.DESCRIPTION
 The updated MSP go-to module from Wade Bachelder
 
#>
 
Param()


function wbMSPfireWallOn {
    NetSh Advfirewall set allprofiles state on;
    Write-Output "Advanced Firewall is set.";
}

function wbMSPfireWallOff {
    NetSh Advfirewall set allprofiles state off;
    Write-Output "Advanced Firewall is off.";
}
function wbMSPsetPowerState {
    Powercfg.exe /h off;
    Powercfg /x -disk-timeout-ac 0;
    Powercfg /x -disk-timeout-dc 0;
    Powercfg /x -monitor-timeout-ac 30;
    Powercfg /x -monitor-timeout-dc 30;
    Powercfg /x -standby-timeout-ac 0;
    Powercfg /x -standby-timeout-dc 0;
    Powercfg /x -hibernate-timeout-ac 0;
    Powercfg /x -hibernate-timeout-dc 0; 
    Write-Output "Power Configuration has been set.";   
}
function wbMSPshowMemoryProcesses {
    Get-Process | Sort-Object -Descending WS;
    Write-Output "Memory processes has been completed.";   
}

function wbMSPsetLaptopPower {
    Powercfg -setacvalueindex 381b4222-f694-41f0-9685-ff5bb260df2e 4f971e89-eebd-4455-a8de-9e59040e7347 5ca83367-6e45-459f-a27b-476b1d01c936 0;
    Powercfg -setdcvalueindex 381b4222-f694-41f0-9685-ff5bb260df2e 4f971e89-eebd-4455-a8de-9e59040e7347 5ca83367-6e45-459f-a27b-476b1d01c936 0;
    Write-Output "Power Configuration for laptop has been set.";   
}

function wbMSPsetRegistry {
   Try{New-ItemProperty -ErrorAction Stop -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" -PropertyType DWORD -Name 'EnableLinkedConnections' -Value 1;}
    Catch{Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" -Name 'EnableLinkedConnections' -Value 1;}
    Set-ItemProperty -Path "HKLM:\System\CurrentControlSet\Control\Terminal Server" -name "fDenyTSConnections" -value 0;
    New-Item -Path "HKLM:\SOFTWARE\Microsoft\Office\16.0\Common\Open Find\" -Force | Out-Null;
    Try{New-ItemProperty -ErrorAction Stop -Path "HKLM:\SOFTWARE\Microsoft\Office\16.0\Common\Open Find\" -PropertyType DWORD -Name 'EnableShellDataCaching' -Value 1;}
    Catch{Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Office\16.0\Common\Open Find\" -Name 'EnableShellDataCaching' -Value 1;}
    Write-Output "Registry for Enabled Linked Connections, Deny connections and Shell Data Caching has been set.";   
}

function wbMSPcheckHDHealth {
    Get-PhysicalDisk;
    Write-Output "Getting information about the disk is complete."; 
}

function wbMSPoptimizeHD {
    Optimize-Volume -DriveLetter C -Defrag -Verbose;
    Write-Output "Optimization of the disk is complete.";
}

function wbMSPrepairHD {
    Repair-Volume -DriveLetter C -OfflineScanAndFix;
    Write-Output "Repair of the disk is complete.";
}

function wbMSPsophosUpdateScan {
    $process = Get-Process -Id $pid;
    $process.PriorityClass = 'BelowNormal';
    $sophos = New-Object -ComObject "activelinkclient.clientupdate.1";
    $sophos.updatenow($true,1);
    $Sophos = "C:\Program Files (x86)\Sophos\Sophos Anti-Virus\sav32cli.exe";
    $Arguments = "-remove";
    Start-Process $Sophos -ArgumentList $Arguments -NoNewWindow -Wait;
    Write-Output "Sophos Update is complete.";
}

function wbMSPwindowsStabilityIndex {
    Get-Ciminstance Win32_ReliabilityStabilityMetrics | Measure-Object -Average -Maximum  -Minimum -Property systemStabilityIndex;
    Write-Output "Reliability Metrics is complete.";
}

function wbMSPwindowsCounters {
    Get-Counter;
    Write-Output "Getting counter information is complete.";
}

function wbMSPlistTop10Files {
    $process = Get-Process -Id $pid;
    $process.PriorityClass = 'BelowNormal';
    Get-ChildItem c:\ -r| sort -descending -property length | select -first 10 name, Length;
    Write-Output "Getting information about the top 10 files is complete.";
}

function wbMSPnetworkDiscoveryOn {
    Netsh advfirewall firewall set rule group="Network Discovery" new enable=Yes;
    Write-Output "Network Discovery has been set.";
}

function wbMSPfileDiscoveryOn {
    Netsh advfirewall firewall set rule group="File and Printer Sharing" new enable=Yes;
    Write-Output "Printer Sharing has been set.";
}

function wbMSPrenameWorkstation {
    $NewSerialNumber = (gwmi win32_bios).SerialNumber;
    Rename-computer -NewName $NewSerialNumber -force;
    Write-Output "Rename of the workstation has been set.";
}

function wbMSPGeneralDiskCleanUp {
    Get-ChildItem "C:\Windows\SoftwareDistribution\*" -Recurse -Force -verbose -ErrorAction SilentlyContinue | Remove-Item -Force -Verbose -Recurse -ErrorAction SilentlyContinue;
    Get-ChildItem "C:\Windows\prefetch\*" -Recurse -Force -verbose -ErrorAction SilentlyContinue | Remove-Item -Force -Verbose -Recurse -ErrorAction SilentlyContinue;
    Get-ChildItem "C:\Users\*\AppData\Local\Temp\*" -Recurse -Force -verbose -ErrorAction SilentlyContinue | Remove-Item -Force -Verbose -Recurse -ErrorAction SilentlyContinue;
    Get-ChildItem "C:\Users\*\AppData\Local\Microsoft\Windows\Temporary Internet Files\*" -Recurse -Force -verbose -ErrorAction SilentlyContinue | Remove-Item -Force -Verbose -Recurse -ErrorAction SilentlyContinue;
    Get-ChildItem "C:\Windows\system32\wbem\Logs\*" -Force | Remove-Item -Recurse -ErrorAction SilentlyContinue;
    Get-ChildItem "C:\Windows\system32\Logfiles\*" -Force | Remove-Item -Recurse -ErrorAction SilentlyContinue;
    Get-ChildItem "C:\Windows\Debug\*" -Force | Remove-Item -Recurse -ErrorAction SilentlyContinue;
    Get-ChildItem "C:\Windows\Downloaded Program Files\*" -Force | Remove-Item -Recurse -ErrorAction SilentlyContinue;
    Get-ChildItem "C:\Windows\LiveKernelReports\*" -Force | Remove-Item -Recurse -ErrorAction SilentlyContinue;
    Get-ChildItem "C:\Users\*\AppData\Local\Microsoft\Windows\Temporary Internet Files\Content.MSO\*" -Force | Remove-Item -Recurse -ErrorAction SilentlyContinue;
    Get-ChildItem "C:\Users\*\AppData\Local\Microsoft\Windows\Temporary Internet Files\Content.Word\*" -Force | Remove-Item -Recurse -ErrorAction SilentlyContinue;
    Get-ChildItem "C:\Users\*\AppData\Local\Microsoft\Windows\Temporary Internet Files\Low\*" -Force | Remove-Item -Recurse -ErrorAction SilentlyContinue;
    Get-ChildItem "C:\Users\*\AppData\Local\Microsoft\Windows\Temporary Internet Files\Content.Outlook\*" -Force | Remove-Item -Recurse -ErrorAction SilentlyContinue;
    Get-ChildItem "C:\Users\*\AppData\Local\Microsoft\Windows\Temporary Internet Files\Content.IE5\*" -Force | Remove-Item -Recurse -ErrorAction SilentlyContinue;
    Get-ChildItem "C:\Users\*\AppData\Roaming\Microsoft\Internet Explorer\UserData\Low\*" -Force | Remove-Item -Recurse -ErrorAction SilentlyContinue;
    Get-ChildItem "C:\Users\*\AppData\Local\Microsoft\Windows\WER\ERC\*" -Force | Remove-Item -Recurse -ErrorAction SilentlyContinue;
    Get-ChildItem "C:\Users\*\AppData\Local\Microsoft\Windows\INetCache\*" -Force | Remove-Item -Recurse -ErrorAction SilentlyContinue;
    Get-ChildItem "C:\Users\*\AppData\Local\Google\Chrome\User Data\Default\Cache\*" -Force | Remove-Item -Recurse -ErrorAction SilentlyContinue;
    Get-ChildItem "C:\Windows.old\*" -Recurse -Force -verbose -ErrorAction SilentlyContinue | Remove-Item -Force -Verbose -Recurse -ErrorAction SilentlyContinue;
    Get-ChildItem "C:\Windows10Upgrade\*" -Recurse -Force -verbose -ErrorAction SilentlyContinue | Remove-Item -Force -Verbose -Recurse -ErrorAction SilentlyContinue;
    Get-ChildItem 'C:\$Recycle.Bin\*' -Force | Remove-Item -Recurse -ErrorAction SilentlyContinue;
    get-psdrive -psprovider filesystem;
    Write-Output "Disk clean up has completed.";
}

function wbMSPPackageCleanUp {
    Get-ChildItem "C:\Users\*\AppData\Local\Packages\*" -Force | Remove-Item -Recurse -ErrorAction SilentlyContinue;
    get-psdrive -psprovider filesystem;
    Write-Output "Clean up of App Packages has completed.";
}
function wbMSPTEAMSCleanUp {
    Get-ChildItem "C:\Users\*\AppData\Roaming\Microsoft\Teams\*" -Force | Remove-Item -Recurse -ErrorAction SilentlyContinue;
    get-psdrive -psprovider filesystem;
    Write-Output "Clean up of Teams has completed.";
}
function wbMSPMPUpdate {
   Update-MpSignature;
   Write-Output "Update-MpSignature has been updated.";
}

function wbMSPAppLogs {
  Get-EventLog -logName "Application" -newest 500 | Select MachineName,TimeGenerated,EntryType,Source,Message;
  Write-Output "Application logs has completed.";
}

function wbMSPSecurityLogs {
  Get-EventLog -logName "Security" -newest 500 | Select MachineName,TimeGenerated,EntryType,Source,Message;
  Write-Output "Security logs has completed.";
}

function wbMSPSystemLogs {
  Get-EventLog -logName "System" -newest 500 | Select MachineName,TimeGenerated,EntryType,Source,Message;
  Write-Output "System logs has completed.";
}

function wbMSPcheckBLVolume {
  Get-BitLockerVolume;
  Write-Output "BitLocker Volume has completed.";
}

function wbMSPcheckBLStatus {
  manage-bde -status;
  Write-Output "BitLocker Status has completed.";
}

function wbMSPQuickScan {
  Start-MpScan -ScanType QuickScan;
  Write-Output "Quickscan has completed.";
}