Powelshell CLI & Command Reference

Powershell:Citrix ‘Always add Asnp citrix.* @ starting of command or script’ run in XD environment

>Powershell cli is not a case-sensitive command line utility.

  • Get-configzone |select name, controllernames — to get XD zone name along with DDCs
  • Get-brokercontroller -state active | select DNSname — active DDCs/Broker info
  • Get-BrokerMachine -MachineName domain\VDI name |select sessionusername,Sessionstarttime, machinename,DesktopGroupName — to get details of User who logged in the specific VDI
  • Get-BrokerMachine -Filter { registrationState -eq ‘unregistered‘ -and HypervisorConnectionUid -eq 2 } | Select machinename — unregistered VDIs info.
  • Get-BrokerMachine -Filter { registrationState -eq ‘unregistered‘ -and HypervisorConnectionUid -eq 2 -and Desktopgroupname -eq “del. group name” } | Select machinename, Desktopgroupname — unregistered VDIs from particular Delivery group. 
  •  

Note:  Sometimes we get this warning if output contains info more than 250 lines. Only first 250 records returned. Use -MaxRecordCount to retrieve more.
Normal commands:-
1.Cluster commands:

    • cluster netint —- Interfaces status
    • cluster res     —- Resources status

 

  • cluster res /prop —- Cluster resources and properties

 

 

  • cluster group —- Listing status for all available resource groups

 

 

  • cluster node —- Listing status for all available nodes
  • PowerShell -Command “&{Import-Module FailoverClusters}” ; “&{get-Clustergroup}” — To get list of cluster group status using PS.

 

 

2. WMIC commands

  • wmic useraccount where (name=’administrator’ and domain=’user domain netBIOS only’) get name,sid —- to know the SID of domain user.
  • wmic useraccount where (name=’administrator’ and domain=’system name’) get name,sid —- to know the SID of Local admin.
  • To Know the user name of SID

$objSID = New-Object System.Security.Principal.SecurityIdentifier `
(“S-1-5-21-XXXXXXXXXX-XXXXXXXXXX-XXXXXXXXX-XXXXXX”) # here enter SID details.

$objUser = $objSID.Translate( [System.Security.Principal.NTAccount])
$objUser.Value

  • wmic logicaldisk get size,freespace,caption: To list out all partitions info in a server/system.
  • wmic NIC where NetEnabled=true get Name, Speed —-to know NIC’s speed.
  • wmic qfe list or wmic /node:server qfe get hotfixid,installedon Wmic commands to get hotfix info installed on server
  • wmic os get name –To know the installed OS on server
  • wmic product where “name LIKE ‘%java%'” get * /format:textvaluelist —-Command to determine installed Java version in a Server
  • wmic csproduct get uuid – Command to find UUID of a server/system

3. Other commands

    • ping -a —Ping reply status with hostname
    • qwinsta  — To know RDP sessions status of a server
    • rwinsta or reset session —- To terminate RDP sessions of a server.
    • msra.exe —- To take remote assistance of other user session.
    • logoff  @session ID@ /v — To terminate particular RDP session
    • logoff  sessionID /Servername:<server hostname) /v — To terminate particular RDP session in remote server/machine.

 

  • fsutil volume diskfree c: —— free space C-disk (to know other disk details change drive letter)
  • chkntfs c:    —– Show – Disk status & checks if c-disk is dirty or not

 

 

  • net user  —-list local user accounts. More about net user.
  • net user “local system username” /active:yes —> to enable (no:for disable) local user account.
  • net user localadmin — #3edC$4rfV is best password we can use to reset local admin password from command prompt.
  • Winver or Ver or wmic os get Caption,CSDVersion /value—– To know the version of the OS
  • systeminfo | findstr /C:”OS”:Command to display info about OS.

 

 

  • netstat -a -b   —-Running services with port numbers
  • netstat -aon  &  netstat -anob   —Port details along with PIDs

 

 

  • netstat -b -v -n —-Running processes with IP/port numbers
  • netstat –ano ¦find /i “listening”—Listening port details with PIDs

 

 

  • schtasks  —Scheduled tasks-win2k3
  • Tasklist /v /fi “Imagename eq “processname” –to list out all the details of particular process.
  • at  — Scheduled tasks-win2k
  • net stop “service name” && net start “service name”—– for restarting service 
  • type <log file> —-To view the log file content 
  • mountvol — to know the GUID of disk/partition
  • wevtutil– To retrieve information about event log.(2K8, W7, Vista)
  • eventquery —To retrieve information about event log.(2K3)
  • query termserver/domain:— Command to know terminal server in a domain.
  • subst : :\create a virtual drive (replica of physical drive)
  • Get-WmiObject win32_quickfixengineering or get-hotfix —ps commands to get hotfix info installed on server 
  • Cacls or icacls —To know the permissions of share folder
  • openssl version— Command to find open SSL version to know more run openssl/?
  • forfiles /p “D:\Test folder” /d -30 /m “*.*” /c “cmd /c del @file /s /q”Command to delete last one month files in a folder.
  • DISM /online /Cleanup-Image /SpSuperseded—To clear winsxs folder (*2008 R2 onwards) or installed hot fix for disk cleanup option https://support.microsoft.com/en-gb/kb/2852386

 

4. Commands for AD
***use switch  /?  after the command for more options: AD command are more important and each one having its own significance.
  • ServerManagerCmd.exe -queryCommand to display roles in WS2008
  • command to display the time difference between the local computer and a target computer: w32tm /stripchart /computer: target /samples: n /dataonly
  • command to configure the PDC emulator: w32tm /config /manualpeerlist: peers /syncfromflags:manual /reliable:yes /update where peers specifies the list of DNS names or IP addresses of the NTP time source that the PDC emulator synchronizes
  • ntdsutil —- Best command used in AD for almost all the issues like (configuration/transfer/seize of fsmo roles, maintenance and restoration of AD database etc)
  • repadmin —-Best command used especially for replication checks. for example repadmin/failcache for replication failures add switch “/v” for verbose mode.
  • repadmin/replsingleobj —for single object replication for more details follow the link http://technet.microsoft.com/en-us/library/cc742123(WS.10).aspx
  • replmon — Best tool helps us to monitor replication issues.
  • ntfrsutl forcerepl [computer] /r SetName /p PartnerDnsName –Force FRS to start a replication cycle ignoring the schedule.
  • ldp  —- Command/tool help us to fix replication issues.
  • dcdiag—- Domain controller Diagnostics. for examples dcdiag/test:replications for replication info and dcdiag/test:dns for DNS server issue etc.
  • netdom  Lot can do with it in a domain/forest. for example to know the info about the servers holding fsmo roles netdom query fsmo. Also using this command we can add computers into domain and lot many can do with it.
  • nltest — for example to know the list DCs in domain nltest/dclist:domain name. Help to know the status of trusts and plays major role in configuration of secure channel authentication.
  • nltest/dsgetsite—To know site which your system/server belongs to
  • netsh dhcp show server–Display the List of Authorized Servers in Active Directory for the Current Domain.
  • netsh interface ipv4 show interface—Display IP packet size(MTU) of NICs.
  • dsquery —- gives us to know the details about AD like (users, groups, OUs and fsmo roles etc.)
  • nslookup — used to know/resolve DNS server issues.
  • csvde command will help us to create bulk users in AD.
  • ldifde another one similar to csvde
  • for /f %i in (userlist.txt) do dsquery user -samid %i | dsrm -noprompt —to delete bulk users in single step.
  • set — Especially at client level and great command to give enough details about domain.
  • set -l  or echo %logonserver% commands to know logon server you logged in.
  • “c:\Program Files\Trend Micro\OfficeScan Client\PccNTUpd.exe” -to update office scan and restart real time scan service.
  • dnscmd/EnumZones —Command to get the zone file data
  • dcgpofixused to reset the Default Domain Group Policy Objects
Other Registry references:
  • Program’s shortcuts of startmenu
C:\Users\USERNAME\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\User Pinned\start menu
  • Program’s shortcuts of taskbar
C:\Users\USERNAME\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar
 
MS Command line reference A-Z: http://technet.microsoft.com/en-us/library/cc754340(v=ws.10)***run these commands with admin rights for better results.

Friends still more commands have to come to this post. Since I’ve started today need more time to update all the commands.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s


»
%d bloggers like this: