Wednesday, September 9, 2015

PowerShell - Uninstall Sophos Antivirus Programs

1. Stop the Sophos AutoUpdate Service to prevent a potential update during the removal process.
2. Gather information for all Sophos applications.
3. Uninstall the applicaions

Enter-PSSession IP_ADDRESS -Credential $cred
net stop "Sophos AutoUpdate Service"
Get-WmiObject -Class win32_product -Filter "Name like '%sophos%'"
$obj = Get-WmiObject -Class win32_product -Filter "Name like '%sophos%'"
$obj.Uninstall()

Monday, May 18, 2015

PowerShell - Detect/Change/Activate Power Plans

Detect Computer power plans
gwmi -NS root\cimv2\power -Class win32_PowerPlan | select ElementName, IsActive | ft -a

Change/Activate power plan
 - Method 1: Using the CIM cmdlets
$powerplan = Get-CimInstance -Name root\cimv2\power -Class win32_PowerPlan -Filter "ElementName = 'High Performance'"
Invoke-CimMethod -InputObject $powerplan -MethodName Activate
$powerplan = Get-CimInstance -Name root\cimv2\power -Class win32_PowerPlan -Filter "ElementName = 'Power Saver'"
Invoke-CimMethod -InputObject $powerplan -MethodName Activate
 - Method 2: Using Get-WmiObject
$powerplan = gwmi -NS root\cimv2\power -Class win32_PowerPlan -Filter "ElementName ='High Performance'"
$powerplan.Activate()
$powerplan = gwmi -NS root\cimv2\power -Class win32_PowerPlan -Filter "ElementName ='Power Saver'"
$powerplan.Activate()

Turn Off Hard Drive Sleep
powercfg -CHANGE -disk-timeout-ac 0

Tuesday, April 7, 2015

PowerShell - Check Hard Drive Size

 Get C: Drive size
$disk = ([wmi]"\root\cimv2:Win32_logicalDisk.DeviceID='C:'")
"C: has {0:#.0} GB free of {1:#.0} GB Total" -f ($disk.FreeSpace/1GB),($disk.Size/1GB) | write-output

Monday, March 9, 2015

PowerShell - Print Queue

List Printers
Get-WMIObject -Class Win32_Printer | Select Name,DriverName,PortName,Shared,ShareName | ft -auto

Show Print Queue Status
Get-WMIObject Win32_PerfFormattedData_Spooler_PrintQueue | Select Name, @{Expression={$_.jobs};Label="CurrentJobs"}, TotalJobsPrinted, JobErrors

Delete a print queue (Ex: hp deskjet 960c series)
$p = Get-WmiObject -Class Win32_printer -filter "name='hp deskjet 960c series'"
$p.delete()

Wednesday, February 25, 2015

Mac OS X - Change ComputerName/HostName/LocalHostName via the command line

ComputerName - Used for Computer Name, File Sharing, and AppleTalk.
scutil --set ComputerName "YourComputerName"

HostName - Displayed in the default terminal command prompt.(user@hostname).
scutil --set HostName "YourHostName"

LocalHostName - Used for Bonjour-aware services on the local network.
scutil --set LocalHostName "YourLocalHostName"


Tuesday, January 27, 2015

Convert GPT to MBR via FOG Upload Debug

1. Go to FOG Management interface,
    choose Basic tasks from the host -> Advanced tasks -> Upload - Debug and schedule it

2. run the following command in the command line on the host computer:
fixparts /dev/sda
    ** if this command not found, sftp to the fog server (/sbin/fixparts) and download it.

3. Press 'Y' -> use option "w" -> confirm. Restart the host computer.