Skip to main content

Posts

Showing posts with the label PowerShell

PowerShell Quick Tips: Rename a computer

Rename local computer to W8M1 and restart PS D:\> Rename-Computer -NewName W8M1 -Restart The above command works with Powershell 3.0. For Powershell 2.0, below can be used on an elevated privileges. PS D:\> $computer = Get-WmiObject Win32_ComputerSystem -ComputerName <old_name> PS D:\> $computer.Rename("<new_name>") PS D:\> $os = Get-WmiObject Win32_OperatingSystem PS D:\> $os.psbase.Scope.Options.EnablePrivileges = $true PS D:\> $os.Reboot() Using WMIC to rename a computer D:\> WMIC ComputerSystem where Name="%computername%" call Rename Name=NewName References: http://social.technet.microsoft.com/Forums/en-US/ITCG/thread/c9dcf26a-5476-4199-8311-b101c969a47a/ http://blogs.technet.com/b/askds/archive/2009/02/19/renaming-a-computer-using-wmic-and-how-to-get-around-that-aggravating-invalid-global-switch-error.aspx

Change network category in Windows 8.1

Windows 8.x network category or network profile affects how other Windows machines detects or discover the node. A machine on  a domain or private network will most of the time allow file sharing and printing, more relaxed firewall, etc. For computers with multiple network interfaces changing network profile can be difficult using the GUI. To force a network interface to be in private profile for example you can do: PS c:\> Set-NetConnectionProfile -InterfaceAlias "VirtualBox Host-Only Network" -NetworkCategory Private where: "Virtual Host-Only Network" - is the name associated with the network interface "Private" - is the profile Reference(s): http://www.tinkertry.com/how-to-change-windows-8-1-network-type-from-public-to-private/

Powershell Quick Tips: Start an interactive session on a remote computer

For the Linux/Unix geeks, ssh is preferred way to establish an interactive session to a remote machine. In Windows ssh can also be used but you have to install extra software. To perform interactive task on remote machine (though not as cool as ssh) one can try Powershell. So, to connect to a remote machine MACHINE1, do: C:\>powershell PS C:\>Enter-PSSession -ComputerName MACHINE1 For this to work, you need to have proper credentials on MACHINE1 (I have only tried with users members of domain admins).

PS Quick Tips: Display service start times

PS C:\> Get-WmiObject win32_service | Where-Object {$_.State -eq "Running"} | ForEach-Object {Write-Host ((Get-process -id $_.ProcessId).StartTime)","$_.PathName","$_.DisplayName} Run this in elevated prompt to get correct information. PS C:\> Get-WmiObject win32_service | Where-Object {$_.State -eq "Running"} | ForEach-Object {Write-Host ((Get-process -id $_.ProcessId).StartTime.ToString("yyyy/MM/dd HH:mm:ss.fffff"))","$_.PathName","$_.DisplayName} This add milliseconds to the service information Keywords: PowerShell Process start times