Thursday, February 24, 2022

How to uninstall windows updates in CLI commands?

 To see a list of installed patches

c:\> wmic qfe list

or
c:\> wmic qfe list brief /format:table



To uninstall a listed patch

c:\> wusa /uninstall /kb:<kbnumber>

example:

wusa /uninstall /kb:892890

Monday, February 21, 2022

Cannot use the special principal ‘sa’. Microsoft SQL Server, Error: 15405

 When importing a database in your SQL instance you would find yourself with Cannot use the special principal 'sa'. Microsoft SQL Server, Error: 15405 popping out when setting the sa user as the DBO of the database. To fix this,

Open SQL Management Studio and Click New Query. Type:

USE mydatabase
exec sp_changedbowner 'sa', 'true'

Close the new query and after viewing the security of the sa, you will find that that sa is the DBO of the database.

Tuesday, February 15, 2022

Log Disk Exhaustion Error VMWare vCenter

vCenter Server /storage/log filling up due to localhost_access.log and catalina.log in sso and lookupsvc log directories (85475)


 Symptoms
  1. /storage/log is filling up
  2. You are receiving constant alerts in vCenter Server that /storage/log is above 80%
  3. The output of this command "du -hSx /storage/log |sort -rh |head -30" returns the following directories as the ones using more space:
    • /var/log/vmware/sso/tomcat
    • /var/log/vmware/eam/web
    • /var/log/vmware/lookupsvc/tomcat
    • /var/log/vmware/lookupsvc
  4. Under those directories there are too many localhost_access*.log and catalina*.log files.
  5. localhost_access*.log and catalina*.log are not compressed
 Cause
There is no proper log rotation and compression being performed on these files and it can start filling /storage/log
 Resolution
Currently there is no resolution. VMware is aware of this issue and will fix it in a future release.
 Workaround
Remember: Always take a snapshot of your vCenter Server whenever you are going to make any changes.

1. Copy the files in the attached "configs.zip" file in this KB to the respective file listed below in your vCenter Server Appliance:

configs.zip                 >  Your vCenter Server
-----------                    -------------------
SSO_server.xml              >  /usr/lib/vmware-sso/vmware-sts/conf/server.xml
SSO_logging.properties      >  /usr/lib/vmware-sso/vmware-sts/conf/logging.properties
LOOKSVC_server.xml          >  /usr/lib/vmware-lookupsvc/conf/server.xml
LOOKSVC_logging.properties  >  /usr/lib/vmware-lookupsvc/conf/logging.properties


2. Restart the vmware-stsd and lookupsvc services

service-control --stop vmware-stsd && service-control --start vmware-stsd
service-control --stop lookupsvc && service-control --start lookupsvc


3. Copy "tomcat_compress.cron" located in the attached file "tomcat_compress.zip" in this KB to /etc/cron.d on your vCenter Server appliance.


 

Saturday, October 23, 2021

How to Enable Copy and Paste in the Windows 10 Command Prompt

With Windows 10, Microsoft finally updated the long-neglected command prompt. You can now quickly select and paste text within the command prompt window, but first you have to enable the keyboard shortcuts. Here's how to do it.

Previously if you wanted to copy and paste in the command prompt you had to jump through hoops: Open the context menu with the Alt+E keyboard combination, go to Edit > Mark to tell Windows you want to mark text to select, and then use a lasso tool to create a box around the text you wanted to select. You needed to go back into the context menu to copy and to paste.

The upgraded command prompt in Windows 10 is much simpler. You can copy and paste with the familiar CTRL + C to copy and CTRL + V to paste keyboard shortcuts. To get this functionality, head to the application's properties settings.

1. Open Command Prompt. The quickest way to do this is to click the Windows key, type in cmd, and hit Enter or clicking on the app.


2. Right-click on the command prompt's title bar and choose Properties

3. Uncheck the box next to "Use legacy console (requires relaunch)". This should automatically check the "Enable Ctrl key shortcuts" option.

4. Click OK.

Windows 10: Missing Processor Power Management Settings Option In Advanced Power Options

 It is very possible that you cannot easily reduce the maximum performance of your CPU because the PROCESSOR POWER MANAGEMENT option is missing from ADVANCED POWER OPTIONS.  Fortunately there is an easy fix:

  1. Click the START button and type REGEDIT
  2. Click on REGISTRY EDITOR
  3. Expand HKEY_LOCAL_MACHINE >  SYSTEM  > CurrentControlSet > Control > Power > PowerSettings>  54533251-82be-4824-96c1-47b60b740d00 > bc5038f7-23e0-4960-96da-33abaf5935ec
  4. Right Click in an empty area and select NEW > DWORD(32 Bit) VALUE
  5. Set the name to Attributes and the value to 2
  6. Right click on the START BUTTON and select POWER OPTIONS
  7. click ADDITIONAL POWER OPTIONS (on the right or bottom)
  8. Click CHANGE ADVANCED POWER SETTINGS
  9. Set the PROCESSOR POWER MANAGEMENT > MAXIMUM PROCESSOR STATE > PLUGGED IN and/or ON BATTERY to some lesser number, like 75%


Saturday, September 4, 2021

Essential ESXCLI Commands

 

ESXi Shell and ESXCLI


If it is not already, the first thing you need to do is enable shell on ESXi, something that is generally disabled for security reasons. To enable Shell, follow the steps provided in KB 2004746. Once you enable it, you can use a tool like putty to access Shell via an SSH session. Alternatively, pressing ALT-F1 while in DCUI is one other way of accessing Shell. To run commands in shell, log in as root or with an account having similar privileges.

ESXCLI commands

Accessing ESXi shell using an SSH client or directly from console

 

The esxcli command exposes a number of namespaces against which you can run queries to retrieve information about ESXi as well as configure it. The following table lists the available namespaces on ESXi 6.5 along with a description for each (source: VMware). For earlier ESXi releases, consult the relevant online documentation or run esxcli with no parameters to see which namespaces are available.

CommandDescription
esxcli deviceLists descriptions of device commands.
esxcli elxnetLists descriptions for commands that manage Emulex elxnet drivers.
esxcli esxcliLists descriptions of esxcli commands.
esxcli fcoeFCOE (Fibre Channel over Ethernet) commands
esxcli graphicsGraphics commands
esxcli hardwareHardware namespace. Used primarily for extracting information about the current system setup.
esxcli iscsiiSCSI namespace for monitoring and managing hardware and software iSCSI.
esxcli networkNetwork namespace for managing virtual networking including virtual switches and VMkernel network interfaces.
esxcli nvmeCommands for managing NVMe devices.
esxcli rdmaCommands for monitoring RDMA devices.
esxcli schedManage the shared system-wide swap space.
esxcli softwareSoftware namespace. Includes commands for managing and installing image profiles and VIBs.
esxcli storageIncludes core storage commands and other storage management commands.
esxcli systemSystem monitoring and management command.
esxcli vmNamespace for listing virtual machines and shutting them down forcefully.
esxcli vsanNamespace for Virtual SAN management commands. See the vSphere Storage publication for details.

 

The Top 20 ESXCLI Commands


The following is a compilation of esxcli commands, sorted by namespace, I tend to use on a regular basis. It is by no means exhaustive as there are too many examples to mention. If you want the whole shebang, have a look at VMware’s documentation site.

 

System related commands


#1esxcli system version get

Description: Returns the ESXi build and version numbers.

 

#2esxcli system hostname get

Description: Returns the hostname, domain and FQDN for the host.

 

#3esxcli system stats installtime get

Description: Returns the date and time of when ESXi was installed.

 

#4esxcli system account list

Description: Lists the local users created on the ESXi host.

 

#5esxcli system account add -d=”Altaro Guest” -i=”altaro” -p=”dsfewfewf*3!4404″ -c=”dsfewfewf*3!4404″

Description: This command allows you to create local ESXi users. All the parameters used in the example are mandatory.

 

#6esxcli system maintenanceMode set –enable true

Description: Use this command to put ESXi in maintenance mode or take it out.

 

#7esxcli system shutdown reboot -d 10 -r “Patch Updates”

Description: Use this command to reboot or shutdown ESXi. The -d parameter is a countdown timer; minimum 10 seconds. ESXi must be in maintenance mode before you can use the command.

 

Network related commands


#8esxcli network firewall get

Description: Returns the status of the ESXi firewall. The default action is to drop traffic unless allowed through by a specific firewall rule. The Enabled field indicates whether the firewall is enabled. The Loaded field shows whether the firewall module is active or not (see esxcli firewall load | unload commands).

 

#9esxcli network firewall set –enabled true | false

Description: Use this command to disable the ESXi firewall for troubleshooting purposes. Note that disabling the firewall on ESXi is highly discouraged.

 

#10esxcli network firewall ruleset list | awk ‘$2 ==”true”‘

Description: Generates a list of all enabled firewall rules on ESXi. The command is piped to awk which will matches the value from the second column to “true” so only enabled rules are displayed.

 

#11esxcli network ip interface ipv4 get

Description: Displays the IPv4 configuration for all the interfaces present on ESXi.

 

Software related commands


#12esxcli software vib list

Description: Lists all the currently installed VIBs on ESXi. A VIB is a file packaging format used to distribute software on ESXi.

 

#13esxcli software vib update -d “/tmp/update.zip”

Description: Use this command to update an installed VIB on ESXi. Note that the command does not install any new software. Instead it only updates what’s currently installed. Use esxcli software vib install instead when installing new software. The -d parameter specifies the full path to the package being used for the update. As per the next screenshot, I specified a non-existing patch hence the error message.

 

Virtual Machine related commands


#14esxcli vm process list

Description: Lists all the running VMs on the hosts. The World ID can be used with other commands to carry out various tasks related to VMs.

 

#15esxcli vm process kill -w 69237 -t soft

Description: Use this command to kill a running VM such as one that fails to respond to commands. You must first retrieve the VM’s World ID (see command #14) and pass it on using the -w parameter. The -t <soft | hard | force> mandatory parameter sets the type of kill operation. Start with soft so you allow the VM to shut down cleanly. If this does not work, try the hard option which will kill the VM processes immediately as in kill -9. The Force type should only be used as a last resort. If none work, your only option is to reboot ESXi.

 

Storage related commands


#16esxcli storage vmfs extent list

Description: The command generates a list of extents for each volume as well as the corresponding device name to UUID mapping.

 

#17esxcli storage filesystem list

Description: The command lists of all the volumes or datastores accessible by the ESXi host. The output includes the file system type, disk info along with the volume name, path and UUID.

 

iSCSI related commands


#18esxcli iscsi software set –enabled true && esxcli iscsi software get

Description: The above command actually consists of two concatenated commands, which is what && does. The first command enables the iSCSI software adapter and the second verifies that the iSCSI adapter is enabled.

 

#19esxcli iscsi adapter param get -A vmhba65

Description: The command returns metrics for the specified iSCSI adapter. These include the current, minimum and maximum values and whether the listed parameters may be configured or not. The name of the iSCSI adapter you want to be queried is specified via the -A parameter. The adapter name is retrieved using esxcli iscsi adapter list or from the vSphere Web client.

 

Available ESXCLI commands


#20esxcli esxcli command list

Description: Lists all the available namespaces and corresponding commands.

 

Wrap Up


We’ve seen how you can use esxcli to query ESXi as well as it for configuration tasks. It is a great command to master, so make sure you familiarize yourself with it. Hopefully, this post has given you a taste of what it can do and how command line is sometimes better suited at accomplishing a given task such as upgrading ESXi from the command line, something I explain in Patching and Upgrading ESXi using ESXCLI commands.

[the_ad id=”4738″][the_ad id=”4796″]