Posts

Showing posts from March, 2019

Solutions for WMI errors

Solutions for WMI errors Symptoms: When you run wmic commands in a Windows server, you may get errors like below: wmic VOLUME GET Name ERROR: Description = Not Found Below are solutions for WMI errors, yet to be verified: If WMI database is broken, you need to follow this guide: https://msdn.microsoft.com/en-us/library/aa394603(v=vs.85).aspx to run WMI Diagnosis Utility , which will help you to confirm if that is really your issue and then fix it by following this guide: First try: winmgmt /verifyrepository .If the result is shown as inconsistent, go to step 2 winmgmt /salvagerepository winmgmt /verifyrepository - to check again wmi repository had been repaired successfully. If it fails - try fully rebuild the WMI Repository follow these steps: Disable and stop the winmgmt service Remove or rename C:\Windows\System32\wbem\repository Enable and start the winmgmt service Open a CMD prompt as Administrator In the CMD prompt Navigate to C:\Windows\System32\

Windows Servers EOL dates

Windows Servers EOL dates Windows Servers: OS Lifecycle Start Date Mainstream Support End Date Extended Support End Date Windows Server 2008 Service Pack 2 29/4/2009 13/1/2015 14/1/2020 Windows Server 2012 Standard 30/10/2012 9/10/2018 10/10/2023 Windows Server 2016 Standard 15/10/2016 11/1/2022 12/1/2027 Windows Server 2019 Standard 13/11/2018 9/1/2024 9/1/2029 Ref: https://support.microsoft.com/en-my/lifecycle/search/1163 SQL Servers: OS Lifecycle Start Date Mainstream Support End Date Extended Support End Date Icrosoft SQL Server 2008 Service Pack 4 7/7/2014 8/7/2014 9/7/2019 SQL Server 2012 Service Pack 4 11/7/2017 12/7/2022 SQL Server 2016 Service Pack 2 24/4/2018 13/7/2021 14/7/2026 SQL Server 2017 on Windows (all editions) 29/9/2017 11/1

PowerShell Script to get all registry keys and values

Below one liner may help to get all registry keys and their values under given path: Get-Item ' ' | %{Get-ItemProperty -Path $_.PSPath} Example registry path :  HKLM:\SOFTWARE\7-Zip Get-Item ' HKLM:\SOFTWARE\7-Zip'   | %{Get-ItemProperty -Path $_.PSPath} Output: PS C:\> Get-Item 'HKLM:\SOFTWARE\7-Zip' | %{Get-ItemProperty -Path $_.PSPath} Path         : C:\Program Files\7-Zip\ Path64       : C:\Program Files\7-Zip\ PSPath       : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SOFTWARE\7-Zip PSParentPath : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SOFTWARE PSChildName  : 7-Zip PSProvider   : Microsoft.PowerShell.Core\Registry

Get PowerShell version in a Windows system

Ways to get PowerShell version in a Windows system $PSVersionTable.PSVersion (Available in PS version 2 or higher) get-host (For PS version 1) powershell -Command "$PSVersionTable.PSVersion" <- command="" from="" li="" prompt="" run=""> powershell -command "(Get-Variable PSVersionTable -ValueOnly).PSVersion " <- command="" from="" li="" prompt="" run=""> Outputs: $PSVersionTable.PSVersion Major Minor Build Revision ----- ----- ----- -------- 3 0 -1 -1 get-host Name : ConsoleHost Version : 3.0 InstanceId : 9b7e8224-e1d5-4b22-b0cb-53f19cd9c5b8 UI : System.Management.Automation.Internal.Host.InternalHostUserInterface CurrentCulture : en-US CurrentUICulture : en-US PrivateData : Microsoft.PowerShell.ConsoleHost+ConsoleColorProxy IsRunspacePushed : False Runspace

PowerShell command to get last modified files

PowerShell command to get last modified files: Dir " " -r | ? {! $_.PSIsContainer} | sort LastWriteTime | select LastWriteTime, FullName -last 20 | sort LastWriteTime –Descending | ft -autosize Example: Dir " c:\temp " -r | ? {! $_.PSIsContainer} | sort LastWriteTime | select LastWriteTime, FullName -last 20 | sort LastWriteTime –Descending | ft -autosize

Windows environment variables reference

Windows environment variables reference: %UserProfile%\Desktop\  - Current user desktop