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.

Monday, October 27, 2014

Fix "Windows update cannot currently check for updates because the service is not running"

Go to "Control Panel" -> "System and Security" -> "Administrative Tools" -> "Services"
(or use Command Prompt and run "services.msc" to bring up Services control panel)

1: Stop Windows Update Service.

2: Rename/Delete "SoftwareDistribution" folder.
    (Full path: C:\Windows\SoftwareDistribution\)

3: Start Windows Update Service.



Wednesday, September 10, 2014

PowerShell - Change / Mute Audio Volume

Volume Mute Button
$obj = new-object -com wscript.shell
$obj.SendKeys([char]173)

Volume Down Button
$obj = new-object -com wscript.shell
$obj.SendKeys([char]174)

Volume Up Button
$obj = new-object -com wscript.shell
$obj.SendKeys([char]175)

** Each volume counter = 2%
Ex: Set Volume to 50%
Function Set-Speaker($Volume){ $ws = new-object -com wscript.shell;1..50 | % { $ws.SendKeys([char]174)};1..$Volume | % { $ws.SendKeys([char]175) } }
Set-Speaker(25)

PowerShell - Remote Add/Join Computers to domain

$domainAdminCred = Credential
$localAdminCred = Credential

$ScriptBlock = {
  param($domainAdminCred, $computer)
  $domain = "Domain"
  Write-Host "[processing '$computer' ...]"
  Add-Computer -DomainName $domain -Credential $domainAdminCred -OUPath "OU=group1,DC=testing,DC=com" -Restart -Force
}

$IP = "192.168.1.101"
$computer = "PC-01"
Invoke-Command $IP -ScriptBlock $ScriptBlock -ArgumentList $domainAdminCred, $computer -Credential $localAdminCred
$IP = "192.168.1.102"
$computer = "PC-02"
Invoke-Command $IP -ScriptBlock $ScriptBlock -ArgumentList $domainAdminCred, $computer -Credential $localAdminCred