<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Windows |</title><link>https://www.teksyn.net/guides/operating-systems/windows/</link><atom:link href="https://www.teksyn.net/guides/operating-systems/windows/index.xml" rel="self" type="application/rss+xml"/><description>Windows</description><generator>HugoBlox Kit (https://hugoblox.com)</generator><language>en-us</language><lastBuildDate>Thu, 25 Jul 2024 15:18:10 -0500</lastBuildDate><image><url>https://www.teksyn.net/media/logo.svg</url><title>Windows</title><link>https://www.teksyn.net/guides/operating-systems/windows/</link></image><item><title>Cool Powershell Commands</title><link>https://www.teksyn.net/guides/operating-systems/windows/cool-powershell-commands/</link><pubDate>Thu, 25 Jul 2024 15:18:10 -0500</pubDate><guid>https://www.teksyn.net/guides/operating-systems/windows/cool-powershell-commands/</guid><description>&lt;h1 id="introduction"&gt;Introduction&lt;/h1&gt;
&lt;p&gt;PowerShell is a task automation and configuration management framework from Microsoft. It consists of a command-line shell and associated scripting language built on the .NET framework. Here are key points about PowerShell:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Command-Line Interface (CLI)&lt;/strong&gt;: PowerShell provides a robust CLI for managing and automating the administration of Windows and other systems.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Scripting Language&lt;/strong&gt;: PowerShell&amp;rsquo;s scripting language enables administrators to write scripts to automate complex tasks and manage systems programmatically.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Cmdlets&lt;/strong&gt;: PowerShell uses cmdlets, which are specialized .NET classes, to perform specific operations. Examples include Get-Process, Stop-Service, and Set-Item.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Pipelines&lt;/strong&gt;: PowerShell allows the output of one cmdlet to be passed as input to another, enabling powerful and flexible data processing and task automation.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Cross-Platform&lt;/strong&gt;: PowerShell Core (now simply PowerShell) is cross-platform and available on Windows, macOS, and Linux.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Integration&lt;/strong&gt;: PowerShell integrates seamlessly with other Microsoft products and services, making it a valuable tool for managing environments that include Windows servers, Azure cloud services, and more.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Modules&lt;/strong&gt;: It supports modules, which are packages of cmdlets, scripts, functions, and other tools that can extend its functionality.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;PowerShell is a versatile and powerful tool for system administrators and developers to automate and manage system tasks efficiently.&lt;/p&gt;
&lt;h1 id="getting-started"&gt;Getting Started&lt;/h1&gt;
&lt;p&gt;Quick: How to Open Command Prompt or Powershell
In case you do not know how to open the Command Prompt or Powershell and you got here by search engine, the following is a quick guide that will work for Windows XP and beyond:&lt;/p&gt;
&lt;p&gt;For non-administrative commands&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Press [Windows]+[R] or Click on the &amp;ldquo;Start&amp;rdquo; button&lt;/li&gt;
&lt;li&gt;Then, type &lt;code&gt;powershell&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Press [OK] or hit enter&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;For administrative commands&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Click on the &amp;ldquo;Start&amp;rdquo; button&lt;/li&gt;
&lt;li&gt;Then, type &lt;code&gt;powershell&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Choose &amp;ldquo;Run as Administrator&amp;rdquo; or right-click and choose &amp;ldquo;Run as Administrator&amp;rdquo;&lt;/li&gt;
&lt;/ol&gt;
&lt;h1 id="cool-commands"&gt;Cool Commands&lt;/h1&gt;
&lt;h3 id="update-all-applications-on-windows"&gt;Update All Applications on Windows&lt;/h3&gt;
&lt;p&gt;You can update all applications on a Windows machines with two simple commands.&lt;/p&gt;
&lt;p&gt;Type &lt;code&gt;winget upgrade&lt;/code&gt; this will list all your applications, their current version, and available versions.&lt;/p&gt;
&lt;p&gt;Type &lt;code&gt;winget upgrade --all&lt;/code&gt; this will list all out-of-date applications, current versions, available version and start upgrading them.&lt;/p&gt;
&lt;p&gt;You may also get a notice that some version cannot be determined, for these you would need to add the argument &lt;code&gt;--include-unknown&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Type &lt;code&gt;winget upgrade --include-unknown&lt;/code&gt; this will list all your applications, their current version, and available versions.&lt;/p&gt;
&lt;p&gt;Type &lt;code&gt;winget upgrade --all --include-unknown&lt;/code&gt; this will list all out-of-date applications, current versions, available version and start upgrading them.&lt;/p&gt;
&lt;h3 id="testing-tcp-connectivity-with-test-netconnection"&gt;Testing TCP Connectivity with Test-NetConnection&lt;/h3&gt;
&lt;p&gt;You can use the &lt;code&gt;Test-NetConnection&lt;/code&gt; or &lt;code&gt;tnc&lt;/code&gt; for short, which is a function to test connectivity to an address.&lt;/p&gt;
&lt;p&gt;SYNTAX
Test-NetConnection [[-ComputerName] &lt;string&gt;] [-TraceRoute] [-Hops &lt;int&gt;] [-InformationLevel {Quiet | Detailed}]
[&lt;CommonParameters&gt;]&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Test-NetConnection [[-ComputerName] &amp;lt;string&amp;gt;] [-CommonTCPPort] {HTTP | RDP | SMB | WINRM} [-InformationLevel
{Quiet | Detailed}] [&amp;lt;CommonParameters&amp;gt;]
Test-NetConnection [[-ComputerName] &amp;lt;string&amp;gt;] -Port &amp;lt;int&amp;gt; [-InformationLevel {Quiet | Detailed}]
[&amp;lt;CommonParameters&amp;gt;]
Test-NetConnection [[-ComputerName] &amp;lt;string&amp;gt;] -DiagnoseRouting [-ConstrainSourceAddress &amp;lt;string&amp;gt;]
[-ConstrainInterface &amp;lt;uint32&amp;gt;] [-InformationLevel {Quiet | Detailed}] [&amp;lt;CommonParameters&amp;gt;]
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;A quick example I use most is something like this, where you specify the IP address and port you wish to test.
Type &lt;code&gt;Test-NetConnection 192.168.1.1 -port 443&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;This will test&lt;/p&gt;
&lt;h3 id="retrieving-a-file-hash"&gt;Retrieving a File Hash&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;CertUtil -hashfile FileName MD5&lt;/code&gt;
The following rules are as of Windows 7 SP1, Windows Server 2012, and beyond. If they are known to work in older versions, they will be noted with: (independent of Windows version)&lt;/p&gt;
&lt;p&gt;You will need to open a Command Prompt OR Powershell to run this command
** a quick guide to open CMD/Powershell is at the bottom of the answer&lt;/p&gt;
&lt;p&gt;You can find the checksum for a file using ANY of the following hashing algorithms, not JUST MD5:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;MD2 MD4 MD5 SHA1 SHA256 SHA384 SHA512&lt;/code&gt;
To get the current list of supported Hash Algorithms on your specific windows machine (independent of Windows version), run&lt;/p&gt;
&lt;p&gt;&lt;code&gt;CertUtil -hashfile -?&lt;/code&gt;
The full Format is below, optional parameters are in braces - just replace &lt;strong&gt;[HashAlgorithm]&lt;/strong&gt; with your desired hash from above:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;CertUtil -hashfile FileName [HashAlgorithm]&lt;/code&gt;
You can do the command line operation for ANY files, whether they provide a certificate or not (independent of Windows version)&lt;/p&gt;
&lt;p&gt;If you leave off the &lt;strong&gt;[HashAlgorithm]&lt;/strong&gt;, it will default to the SHA1 checksum of your chosen file&lt;/p&gt;
&lt;p&gt;Its HELPFUL to note that &lt;strong&gt;[HashAlgorithm]&lt;/strong&gt; is case INsensitive in both CMD and Powershell meaning you can do any of the following (for example):&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-fallback" data-lang="fallback"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;CertUtil -hashfile md5
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Certutil -hashfile MD5
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;certUtil -hashfile sHa1
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;certutil -hashfile SHA256
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description></item></channel></rss>