<p>When I run Kubernetes commands, Powershell is wanting me to use the path to the kubectl.exe instead of just using the command kubectl.</p>
<p>I'm told using an Alias would work but I'm not sure how to do that in this case with Powershell and my attempts have come up fruitless.</p>
<p>This is what I tried:</p>
<p><a href="https://stackoverflow.com/questions/65855456/how-to-make-an-alias-for-kubectl-in-windows-using-env-variables">How to make an alias for Kubectl in Windows using ENV Variables?</a></p>
<p>I tried running this:
<code>C:\Aliases&gt; New-Item -ItemType File -Path C:\Aliases\&quot;K.bat&quot; -Value &quot;doskey k=kubectl $*&quot; -Force</code></p>
<p>And made a system Environment Variable with Aliases as the name and C:\Aliases as the value.</p>
<p>typing K, k, kubectl, etc. was not returning anything that looked like it was being set as an alias.</p>

burntcookie
<p>Place the following in your <a href="https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_Profiles" rel="nofollow noreferrer"><code>$PROFILE</code></a> file (open it for editing with, e.g., <code>notepad $PROFILE</code>; if it doesn't exist, create it with <code>New-Item -Force $PROFILE</code> first):</p>
<pre><code>Set-Alias k kubectl.exe
</code></pre>
<p>If <code>kubectl.exe</code> isn't in a directory listed in <code>$env:PATH</code>, specify the full path instead (substitute the real directory path below):</p>
<pre><code>Set-Alias k 'C:\path\to\kubectl.exe'
</code></pre>
<p>This allows you to invoke <code>kubectl.exe</code> with <code>k</code> in future sessions.</p>
<p>(The post you link to is for <code>cmd.exe</code> (Command Prompt), not PowerShell.)</p>
