Rename-Computer -ComputerName "OLD_COMPUTER_NAME" -NewName "NEW_COMPUTER_NAME" -DomainCredential $cred
Showing posts with label Windows 7. Show all posts
Showing posts with label Windows 7. Show all posts
Friday, March 25, 2016
PowerShell - Rename Computer in Active Directory
Execute the command below and restart the computer.
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
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
Change/Activate power plan
- Method 1: Using the CIM cmdlets
Turn Off Hard Drive Sleep
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'"- Method 2: Using Get-WmiObject
Invoke-CimMethod -InputObject $powerplan -MethodName Activate
$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
Show Print Queue Status
Delete a print queue (Ex: hp deskjet 960c series)
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()
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:
3. Press 'Y' -> use option "w" -> confirm. Restart the host computer.
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)
(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
Volume Down Button
Volume Up Button
** Each volume counter = 2%
Ex: Set Volume to 50%
$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:
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.
-----------------------------------------------------------------------------------------------
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.
-----------------------------------------------------------------------------------------------
Thursday, August 7, 2014
PowerShell - Remote Configure Static/DHCP IP Address
For Static IP:
For DHCP 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 - 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)FManage 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
Generate a list of installed applications.
Uninstall a specific application (Ex: uninstall Java 7 Update 51)
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
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")
Friday, September 27, 2013
CCTK - Remote Manage Dell BIOS
1. Download and install the Dell Client Configuration Toolkit - CCTK
2. Use Dos Prompt and change directory to C:\Program Files (x86)\Dell\CCTK\X86_64\
View boot order:
** For some reasons, "CCTK --valsetuppwd" not accepting the correct password.
Solution:
Examples of the PowerShell command:
Setup BIOS PASSWORD:
2. Use Dos Prompt and change directory to C:\Program Files (x86)\Dell\CCTK\X86_64\
View boot order:
cctk.exe bootorderChange boot order: (ex: 1=Hard Disk, 2=USB device, 3=CDRom, 4=Embedded NIC)
cctk.exe bootorder --sequence=1,4,2,3 --valsetuppwd=PASSWORDEnable Device: (ex: 1=Hard Disk, 2=USB device, 3=CDRom, 4=Embedded NIC)
cctk.exe bootorder --enabledevice=4 --valsetuppwd=PASSWORDDisable Device: (ex: 1=Hard Disk, 2=USB device, 3=CDRom, 4=Embedded NIC)
cctk.exe bootorder --disabledevice=2 --valsetuppwd=PASSWORD
** For some reasons, "CCTK --valsetuppwd" not accepting the correct password.
Solution:
cctk.exe --valsetuppwd=PASSWORD --setuppwd=
cctk.exe bootorder --sequence=hdd,embnic,usbdev,cdrom
cctk.exe --setuppwd=PASSWORD
Examples of the PowerShell command:
Setup BIOS PASSWORD:
Invoke-Command -ComputerName COMPUTERNAME -scriptblock { &'C:\Program Files (x86)\Dell\CCTK\X86_64\cctk.exe' --setuppwd=PASSWORD }Remove BIOS PASSWORD:
Invoke-Command -ComputerName COMPUTERNAME -scriptblock { &'C:\Program Files (x86)\Dell\CCTK\X86_64\cctk.exe' --valsetuppwd=PASSWORD --setuppwd= }Wake On Lan Without PXE:
Invoke-Command -ComputerName COMPUTERNAME -scriptblock { &'C:\Program Files (x86)\Dell\CCTK\X86_64\cctk.exe' --embnic1=onnopxe }Force PXE On Next Boot:
Enter-PSSession -ComputerName COMPUTERNAME
&"C:\Program Files (x86)\Dell\CCTK\X86_64\cctk.exe" --embnic1=on
&"C:\Program Files (x86)\Dell\CCTK\X86_64\cctk.exe" --forcepxeonnextboot=enable
Exit
Monday, August 19, 2013
Uninstall Internet Explorer 10 Silently
Please make sure IE is closed on the machine before proceeding.
FORFILES /P C:\Windows\servicing\Packages /M Microsoft-Windows-InternetExplorer-*10.*.mum /c "cmd /c echo Uninstalling package @fname && start /w pkgmgr /up:@fname /norestart /quiet"
shutdown -r
Subscribe to:
Posts (Atom)