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

Thursday, August 21, 2014

DHCP Testing Command

Bring up Command Prompt and run:
netsh dhcp show server

Will receive the following result:
-----------------------------------------------------------------------------------------------
1 Servers were found in the directory service:

        Server [pdcsc.server.com] Address [192.168.100.1] Ds location: cn=pdcs
.server.com

Command completed successfully.
-----------------------------------------------------------------------------------------------

Wednesday, August 20, 2014

Windows 8.1 Set Network to be Private / Public

1. Use Command Prompt and run "secpol.msc"
2. Click on "Network List Manager Policies"
3. Double-click on your network
4. Click on "Tab Network Location"
5. Set "Location Type" to "Private" (or "Public")

Thursday, August 7, 2014

PowerShell - Remote Configure Static/DHCP IP Address

For Static IP:
$sc = {
param($IP)
$wmi = Get-WmiObject win32_networkadapterconfiguration -filter "ipenabled ='true'";
$wmi.EnableStatic($IP, "255.255.255.0");
$wmi.SetGateways("192.168.1.1", 1);
$wmi.SetDNSServerSearchOrder(@("192.168.1.1","8.8.8.8"))
}

$IP = "192.168.1.101"
$job = Invoke-Command 192.168.1.121 -ScriptBlock $sc -ArgumentList $IP -AsJob -Credential $cred
Wait-Job $job -Timeout 20
$IP = "192.168.1.102"
$job = Invoke-Command 192.168.1.122 -ScriptBlock $sc -ArgumentList $IP -AsJob -Credential $cred
Wait-Job $job -Timeout 20



For DHCP IP:
$sc = {
$wmi = Get-WmiObject win32_networkadapterconfiguration -filter "ipenabled ='true'";
$wmi.EnableDHCP();
$wmi.SetDNSServerSearchOrder();
}

$job = Invoke-Command 192.168.1.101 -ScriptBlock $sc -AsJob -Credential $cred
Wait-Job $job -Timeout 20
$job = Invoke-Command 192.168.1.102 -ScriptBlock $sc -AsJob -Credential $cred
Wait-Job $job -Timeout 20


Wednesday, July 9, 2014

PowerShell - Uninstall Application for Lab Computers Simultaneously

# Loop through the server list
Get-Content -Path "C:\Scripts\Computers.txt" | %{

  # Define what each job does
  $ScriptBlock = {
    param($server)
    Write-Host "[processing '$server' inside the job]"
    $app = Get-WmiObject -Class Win32_Product -computer $server -Filter "Name = 'Java 7 Update 60'"
    $app.Uninstall()
    Start-Sleep 60
  }

  Write-Host "processing $_..."

  # Execute the jobs in parallel
  Start-Job $ScriptBlock -ArgumentList $_
}

Get-Job

While (Get-Job -State "Running")
{
  Start-Sleep 10
}

Get-Job | Receive-Job

Monday, June 30, 2014

PowerShell - Add/Join Computer to domain

$pc = "PC-01"
$domain = "Domain"
$user = "Administrator"
$pass = cat C:\securestring.txt | convertto-securestring
$username = "$domain\$user"
$computer = "NewPCName"
$credential = New-Object System.Management.Automation.PSCredential($username,$pass)
Add-Computer -ComputerName $pc -DomainName $domain -newname $computer -OUPath "OU=group1,DC=testing,DC=com" -Restart -Force -Credential $credential
EXIT

PowerShell - Remove/Unjoin Computer from domain

$pc = "PCName"
$user = "Administrator"
$pass = cat C:\securestring.txt | convertto-securestring
$cred = new-object -typename System.Management.Automation.PSCredential -argumentlist "$pc\$user",$pass
$domain = "Domain"
$user2 = "Administrator"
$pass2 = cat C:\securestring2.txt | convertto-securestring
$domcred = new-object -typename System.Management.Automation.PSCredential -argumentlist "$domain\$user2",$pass2
Remove-Computer -Computer $pc -UnjoinDomainCredential $domcred -LocalCredential $cred -Workgroup workgroup -PassThru -Force -restart

PowerShell - Write Credentials to File


$FilePath = "C:"
Write-Host "Enter login as domain\id:"
Read-Host | Out-File $FilePath\id.txt

Write-Host "Enter user password:"
Read-Host -AsSecureString | ConvertFrom-SecureString | Out-File $FilePath\securestring.txt

Wednesday, June 18, 2014

icacls - Manage file/folder permission to users via the command line

Manage in Command Prompt:
icacls C:\Users\Public\Desktop\Share /grant Everyone:(OI)(CI)F
Manage in PowerShell:
icacls C:\Users\Public\Desktop\Share /grant "Everyone:`(OI`)`(CI`)F"

WMIC - Uninstall application via the command Line

WMIC - Windows Management Instrumentation Command-line

Use Command Prompt and enter "WMIC" to bring up wmic mode
wmic:root\cli>

Generate a list of installed applications.
product get name

Uninstall a specific application (Ex: uninstall Java 7 Update 51)
product where name="Java 7 Update 51" call uninstall
Enter "Y" to continute the uninstallation process

Friday, March 14, 2014

Local Group Policy - Force Windows 7 to Work/Private Network

Open "gpedit.msc" -> Go to Computer Configration –> Windows Settings –> Security Settings –> Network list manager

Wednesday, February 19, 2014

Mac OS X - Enable Screen Sharing (VNC) via the command line

The following command should be typed as one line of text.
sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -activate -configure -access -on -clientopts -setvnclegacy -vnclegacy yes -clientopts -setvncpw -vncpw VNCPASSWORD -restart -agent -privs -all

Thursday, January 30, 2014

PowerShell - Change Computer Name

Execute the command below and restart the computer.

$computerName = Get-WmiObject Win32_ComputerSystem
$name = "New Computer Name"
$computername.rename("$name")

Thursday, January 23, 2014

Mac OS X - Install wget via the command line


curl -O http://rudix.googlecode.com/files/wget-1.12-0.dmg
hdiutil mount wget-1.12-0.dmg
sudo installer -package /Volumes/wget.pkg/wget.pkg -target "/Volumes/Macintosh HD"
hdiutil unmount "/Volumes/wget.pkg/"

Wednesday, January 8, 2014

Enable VNC Remote Controll Macbook Pro


1. Go to System Preferences -> Sharing -> Remote Management
2. Check "Allow access for All Users"
3. Click on "Computer Settings"
4. Check "Anyone may request permission to control screen"
5. Check "VNC viewers may control screen with password" (Enter your own password)
6. Hit "OK" and done.


Tuesday, January 7, 2014

PowerShell - How to Enable-PSRemoting on Windows XP

1. Use Command Prompt and run "Secpol.msc" to bring up Local Security Settings.
2. Go to Local Policies -> Security Options
3. Double click on "Network access: Sharing and security model for local accounts"
4. Change to "Classic - local users authenticate as themselves" and hit OK.
5. Enter PowerShell and execute the following commands:
Enable-PSRemoting -Force
Set-Item wsman:\localhost\client\trustedhosts *
Restart-Service WinRM

Done!


Saturday, January 4, 2014

iPhone/iOS - Change Mac Addres


Supported version: All iOS version (3,4,5, 6, 7)

Change mac address:
nvram wifiaddr=XX:XX:XX:XX:XX

Restore to the original mac address:
nvram -d wifiaddr

Restart iPhone after executing change/restore command above to finish the process:
reboot