How can `Get-Command` return “commands” that aren't really commands?How can I develop for iPhone using a Windows development machine?How can you find out which process is listening on a port on Windows?How do I get current datetime on the Windows command line, in a suitable format for using in a filename?How do I run two commands in one line in Windows CMD?How to count objects in PowerShell?how to run get-vm command on windows powershellCommandNotFoundException: get-windowsoptionalfeatureWhy are scripted cmdlets listed as functions?Get-Command not behaving as describedExecuting `where.exe` within PowerShell

Why military weather satellites?

Could a complex system of reaction wheels be used to propel a spacecraft?

Cauterizing a wound with metal?

Do manacles provide any sort of in-game mechanical effect or condition?

Why does Sauron not permit his followers to use his name?

Heat output from a 200W electric radiator?

Board Chinese train at a different station (on-route)

How to handle inventory and story of a player leaving

Give Lightning Web Component a Prettier Name

Create a list of snaking numbers under 50,000

What caused the end of cybernetic implants?

Count the number of triangles

Under GDPR, can I give permission once to allow everyone to store and process my data?

Does Dovescape counter Enchantment Creatures?

How to save money by shopping at a variety of grocery stores?

“I hope he visit us more often” Why is this wrong?

Where should I draw the line on follow up questions from previous employer

How to determine the convexity of my problem and categorize it?

basename "$0" not working

What is the sound/audio equivalent of "unsightly"?

How to differentiate between two people with the same name in a story?

Why did Lucius make a deal out of Buckbeak hurting Draco but not about Draco being turned into a ferret?

Was a six-engine 747 ever seriously considered by Boeing?

Why haven't the British protested Brexit as ardently like Hong Kongers protest?



How can `Get-Command` return “commands” that aren't really commands?


How can I develop for iPhone using a Windows development machine?How can you find out which process is listening on a port on Windows?How do I get current datetime on the Windows command line, in a suitable format for using in a filename?How do I run two commands in one line in Windows CMD?How to count objects in PowerShell?how to run get-vm command on windows powershellCommandNotFoundException: get-windowsoptionalfeatureWhy are scripted cmdlets listed as functions?Get-Command not behaving as describedExecuting `where.exe` within PowerShell






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















'Get-Command' returns a list of all available commands in a powershell session.



The following code evaluates to $false, when passed a string which is not a command:



function f($x) [bool](Get-Command $x -ErrorAction SilentlyContinue)


And it does:



PS C:Windowssystem32> f ls
True
PS C:Windowssystem32> f alkdsjfasd
False


So you would think that the following code would return the list of commands which are not commands -- that is an empty list:



Get-Command | Where-Object [bool](Get-Command $_ -ErrorAction SilentlyContinue) -eq $false


Except it doesn't. It returns the following on a clean Windows Server 2016 VM:



CommandType Name Version Source
----------- ---- ------- ------
Function Get-IseSnippet 1.0.0.0 ISE
Function Import-IseSnippet 1.0.0.0 ISE
Function New-IseSnippet 1.0.0.0 ISE
Function Start-AutologgerConfig 1.0.0.0 EventTracingManagement
Cmdlet Add-ClusteriSCSITargetServerRole 2.0.0.0 IscsiTarget


If I wait a little while and run the same command again, it returns a much longer list:



CommandType Name Version Source
----------- ---- ------- ------
Function Add-RDServer 2.0.0.0 RemoteDesktop
Function Add-RDSessionHost 2.0.0.0 RemoteDesktop
Function Add-RDVirtualDesktopToCollection 2.0.0.0 RemoteDesktop
Function Disable-RDVirtualDesktopADMachineAccountReuse 2.0.0.0 RemoteDesktop
Function Get-IseSnippet 1.0.0.0 ISE
...
Function Test-RDVirtualDesktopADMachineAccountReuse 2.0.0.0 RemoteDesktop
Function Update-RDVirtualDesktopCollection 2.0.0.0 RemoteDesktop


I've checked the files in the RemoteDesktop module, for example, and I've been able to find the functions that are "missing".



What is going on here? How can 'Get-Command' return "commands" that aren't commands?










share|improve this question
























  • what happens if you run the commands after a period of time on the command line using the -noprofile flag?

    – Ctznkane525
    Mar 27 at 22:20











  • Hmmm ... I'm not sure if I got what the actual question is. Get-Command returns cmdlets, functions and aliasses ... all that depending on the underlying OS and installed modules and products

    – Olaf
    Mar 27 at 22:21












  • @Ctznkane525 The behavior is identical whether or not I start powershell with the -NoProfile switch. The first run outputs a few commands, the second outputs many more.

    – Daniel S
    Mar 28 at 1:19











  • @Olaf It's true that the output of Get-Command is different on different computers, but the output of 'gcm | where [bool](gcm $_ -ErrorAction SilentlyContinue) -eq $false' should always be nothing. No matter what system it's run on. It's like if I take a list of all the files in a folder, and then remove each file that's in the folder, I should be left with an empty list, no matter what folder I do that with.

    – Daniel S
    Mar 28 at 1:34











  • I can't fully account for it, but get-command lists available commands, including modules which are not imported. get-command $_ triggers module auto-import. For one example, the webadministration module on my system claims it will export Begin-WebCommitDelay as an alias, during import as a normal user it errors because I'm not an admin and cannot access IIS configuration data, and then whatever happens it does not export that alias at all and get-command no longer shows it. I suspect the delay of modules auto-importing, and the change of state during import is involved in this.

    – TessellatingHeckler
    Mar 28 at 10:27

















0















'Get-Command' returns a list of all available commands in a powershell session.



The following code evaluates to $false, when passed a string which is not a command:



function f($x) [bool](Get-Command $x -ErrorAction SilentlyContinue)


And it does:



PS C:Windowssystem32> f ls
True
PS C:Windowssystem32> f alkdsjfasd
False


So you would think that the following code would return the list of commands which are not commands -- that is an empty list:



Get-Command | Where-Object [bool](Get-Command $_ -ErrorAction SilentlyContinue) -eq $false


Except it doesn't. It returns the following on a clean Windows Server 2016 VM:



CommandType Name Version Source
----------- ---- ------- ------
Function Get-IseSnippet 1.0.0.0 ISE
Function Import-IseSnippet 1.0.0.0 ISE
Function New-IseSnippet 1.0.0.0 ISE
Function Start-AutologgerConfig 1.0.0.0 EventTracingManagement
Cmdlet Add-ClusteriSCSITargetServerRole 2.0.0.0 IscsiTarget


If I wait a little while and run the same command again, it returns a much longer list:



CommandType Name Version Source
----------- ---- ------- ------
Function Add-RDServer 2.0.0.0 RemoteDesktop
Function Add-RDSessionHost 2.0.0.0 RemoteDesktop
Function Add-RDVirtualDesktopToCollection 2.0.0.0 RemoteDesktop
Function Disable-RDVirtualDesktopADMachineAccountReuse 2.0.0.0 RemoteDesktop
Function Get-IseSnippet 1.0.0.0 ISE
...
Function Test-RDVirtualDesktopADMachineAccountReuse 2.0.0.0 RemoteDesktop
Function Update-RDVirtualDesktopCollection 2.0.0.0 RemoteDesktop


I've checked the files in the RemoteDesktop module, for example, and I've been able to find the functions that are "missing".



What is going on here? How can 'Get-Command' return "commands" that aren't commands?










share|improve this question
























  • what happens if you run the commands after a period of time on the command line using the -noprofile flag?

    – Ctznkane525
    Mar 27 at 22:20











  • Hmmm ... I'm not sure if I got what the actual question is. Get-Command returns cmdlets, functions and aliasses ... all that depending on the underlying OS and installed modules and products

    – Olaf
    Mar 27 at 22:21












  • @Ctznkane525 The behavior is identical whether or not I start powershell with the -NoProfile switch. The first run outputs a few commands, the second outputs many more.

    – Daniel S
    Mar 28 at 1:19











  • @Olaf It's true that the output of Get-Command is different on different computers, but the output of 'gcm | where [bool](gcm $_ -ErrorAction SilentlyContinue) -eq $false' should always be nothing. No matter what system it's run on. It's like if I take a list of all the files in a folder, and then remove each file that's in the folder, I should be left with an empty list, no matter what folder I do that with.

    – Daniel S
    Mar 28 at 1:34











  • I can't fully account for it, but get-command lists available commands, including modules which are not imported. get-command $_ triggers module auto-import. For one example, the webadministration module on my system claims it will export Begin-WebCommitDelay as an alias, during import as a normal user it errors because I'm not an admin and cannot access IIS configuration data, and then whatever happens it does not export that alias at all and get-command no longer shows it. I suspect the delay of modules auto-importing, and the change of state during import is involved in this.

    – TessellatingHeckler
    Mar 28 at 10:27













0












0








0








'Get-Command' returns a list of all available commands in a powershell session.



The following code evaluates to $false, when passed a string which is not a command:



function f($x) [bool](Get-Command $x -ErrorAction SilentlyContinue)


And it does:



PS C:Windowssystem32> f ls
True
PS C:Windowssystem32> f alkdsjfasd
False


So you would think that the following code would return the list of commands which are not commands -- that is an empty list:



Get-Command | Where-Object [bool](Get-Command $_ -ErrorAction SilentlyContinue) -eq $false


Except it doesn't. It returns the following on a clean Windows Server 2016 VM:



CommandType Name Version Source
----------- ---- ------- ------
Function Get-IseSnippet 1.0.0.0 ISE
Function Import-IseSnippet 1.0.0.0 ISE
Function New-IseSnippet 1.0.0.0 ISE
Function Start-AutologgerConfig 1.0.0.0 EventTracingManagement
Cmdlet Add-ClusteriSCSITargetServerRole 2.0.0.0 IscsiTarget


If I wait a little while and run the same command again, it returns a much longer list:



CommandType Name Version Source
----------- ---- ------- ------
Function Add-RDServer 2.0.0.0 RemoteDesktop
Function Add-RDSessionHost 2.0.0.0 RemoteDesktop
Function Add-RDVirtualDesktopToCollection 2.0.0.0 RemoteDesktop
Function Disable-RDVirtualDesktopADMachineAccountReuse 2.0.0.0 RemoteDesktop
Function Get-IseSnippet 1.0.0.0 ISE
...
Function Test-RDVirtualDesktopADMachineAccountReuse 2.0.0.0 RemoteDesktop
Function Update-RDVirtualDesktopCollection 2.0.0.0 RemoteDesktop


I've checked the files in the RemoteDesktop module, for example, and I've been able to find the functions that are "missing".



What is going on here? How can 'Get-Command' return "commands" that aren't commands?










share|improve this question














'Get-Command' returns a list of all available commands in a powershell session.



The following code evaluates to $false, when passed a string which is not a command:



function f($x) [bool](Get-Command $x -ErrorAction SilentlyContinue)


And it does:



PS C:Windowssystem32> f ls
True
PS C:Windowssystem32> f alkdsjfasd
False


So you would think that the following code would return the list of commands which are not commands -- that is an empty list:



Get-Command | Where-Object [bool](Get-Command $_ -ErrorAction SilentlyContinue) -eq $false


Except it doesn't. It returns the following on a clean Windows Server 2016 VM:



CommandType Name Version Source
----------- ---- ------- ------
Function Get-IseSnippet 1.0.0.0 ISE
Function Import-IseSnippet 1.0.0.0 ISE
Function New-IseSnippet 1.0.0.0 ISE
Function Start-AutologgerConfig 1.0.0.0 EventTracingManagement
Cmdlet Add-ClusteriSCSITargetServerRole 2.0.0.0 IscsiTarget


If I wait a little while and run the same command again, it returns a much longer list:



CommandType Name Version Source
----------- ---- ------- ------
Function Add-RDServer 2.0.0.0 RemoteDesktop
Function Add-RDSessionHost 2.0.0.0 RemoteDesktop
Function Add-RDVirtualDesktopToCollection 2.0.0.0 RemoteDesktop
Function Disable-RDVirtualDesktopADMachineAccountReuse 2.0.0.0 RemoteDesktop
Function Get-IseSnippet 1.0.0.0 ISE
...
Function Test-RDVirtualDesktopADMachineAccountReuse 2.0.0.0 RemoteDesktop
Function Update-RDVirtualDesktopCollection 2.0.0.0 RemoteDesktop


I've checked the files in the RemoteDesktop module, for example, and I've been able to find the functions that are "missing".



What is going on here? How can 'Get-Command' return "commands" that aren't commands?







windows powershell windows-server powershell-5.0 powershell-v5.1






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 27 at 22:15









Daniel SDaniel S

11 bronze badge




11 bronze badge















  • what happens if you run the commands after a period of time on the command line using the -noprofile flag?

    – Ctznkane525
    Mar 27 at 22:20











  • Hmmm ... I'm not sure if I got what the actual question is. Get-Command returns cmdlets, functions and aliasses ... all that depending on the underlying OS and installed modules and products

    – Olaf
    Mar 27 at 22:21












  • @Ctznkane525 The behavior is identical whether or not I start powershell with the -NoProfile switch. The first run outputs a few commands, the second outputs many more.

    – Daniel S
    Mar 28 at 1:19











  • @Olaf It's true that the output of Get-Command is different on different computers, but the output of 'gcm | where [bool](gcm $_ -ErrorAction SilentlyContinue) -eq $false' should always be nothing. No matter what system it's run on. It's like if I take a list of all the files in a folder, and then remove each file that's in the folder, I should be left with an empty list, no matter what folder I do that with.

    – Daniel S
    Mar 28 at 1:34











  • I can't fully account for it, but get-command lists available commands, including modules which are not imported. get-command $_ triggers module auto-import. For one example, the webadministration module on my system claims it will export Begin-WebCommitDelay as an alias, during import as a normal user it errors because I'm not an admin and cannot access IIS configuration data, and then whatever happens it does not export that alias at all and get-command no longer shows it. I suspect the delay of modules auto-importing, and the change of state during import is involved in this.

    – TessellatingHeckler
    Mar 28 at 10:27

















  • what happens if you run the commands after a period of time on the command line using the -noprofile flag?

    – Ctznkane525
    Mar 27 at 22:20











  • Hmmm ... I'm not sure if I got what the actual question is. Get-Command returns cmdlets, functions and aliasses ... all that depending on the underlying OS and installed modules and products

    – Olaf
    Mar 27 at 22:21












  • @Ctznkane525 The behavior is identical whether or not I start powershell with the -NoProfile switch. The first run outputs a few commands, the second outputs many more.

    – Daniel S
    Mar 28 at 1:19











  • @Olaf It's true that the output of Get-Command is different on different computers, but the output of 'gcm | where [bool](gcm $_ -ErrorAction SilentlyContinue) -eq $false' should always be nothing. No matter what system it's run on. It's like if I take a list of all the files in a folder, and then remove each file that's in the folder, I should be left with an empty list, no matter what folder I do that with.

    – Daniel S
    Mar 28 at 1:34











  • I can't fully account for it, but get-command lists available commands, including modules which are not imported. get-command $_ triggers module auto-import. For one example, the webadministration module on my system claims it will export Begin-WebCommitDelay as an alias, during import as a normal user it errors because I'm not an admin and cannot access IIS configuration data, and then whatever happens it does not export that alias at all and get-command no longer shows it. I suspect the delay of modules auto-importing, and the change of state during import is involved in this.

    – TessellatingHeckler
    Mar 28 at 10:27
















what happens if you run the commands after a period of time on the command line using the -noprofile flag?

– Ctznkane525
Mar 27 at 22:20





what happens if you run the commands after a period of time on the command line using the -noprofile flag?

– Ctznkane525
Mar 27 at 22:20













Hmmm ... I'm not sure if I got what the actual question is. Get-Command returns cmdlets, functions and aliasses ... all that depending on the underlying OS and installed modules and products

– Olaf
Mar 27 at 22:21






Hmmm ... I'm not sure if I got what the actual question is. Get-Command returns cmdlets, functions and aliasses ... all that depending on the underlying OS and installed modules and products

– Olaf
Mar 27 at 22:21














@Ctznkane525 The behavior is identical whether or not I start powershell with the -NoProfile switch. The first run outputs a few commands, the second outputs many more.

– Daniel S
Mar 28 at 1:19





@Ctznkane525 The behavior is identical whether or not I start powershell with the -NoProfile switch. The first run outputs a few commands, the second outputs many more.

– Daniel S
Mar 28 at 1:19













@Olaf It's true that the output of Get-Command is different on different computers, but the output of 'gcm | where [bool](gcm $_ -ErrorAction SilentlyContinue) -eq $false' should always be nothing. No matter what system it's run on. It's like if I take a list of all the files in a folder, and then remove each file that's in the folder, I should be left with an empty list, no matter what folder I do that with.

– Daniel S
Mar 28 at 1:34





@Olaf It's true that the output of Get-Command is different on different computers, but the output of 'gcm | where [bool](gcm $_ -ErrorAction SilentlyContinue) -eq $false' should always be nothing. No matter what system it's run on. It's like if I take a list of all the files in a folder, and then remove each file that's in the folder, I should be left with an empty list, no matter what folder I do that with.

– Daniel S
Mar 28 at 1:34













I can't fully account for it, but get-command lists available commands, including modules which are not imported. get-command $_ triggers module auto-import. For one example, the webadministration module on my system claims it will export Begin-WebCommitDelay as an alias, during import as a normal user it errors because I'm not an admin and cannot access IIS configuration data, and then whatever happens it does not export that alias at all and get-command no longer shows it. I suspect the delay of modules auto-importing, and the change of state during import is involved in this.

– TessellatingHeckler
Mar 28 at 10:27





I can't fully account for it, but get-command lists available commands, including modules which are not imported. get-command $_ triggers module auto-import. For one example, the webadministration module on my system claims it will export Begin-WebCommitDelay as an alias, during import as a normal user it errors because I'm not an admin and cannot access IIS configuration data, and then whatever happens it does not export that alias at all and get-command no longer shows it. I suspect the delay of modules auto-importing, and the change of state during import is involved in this.

– TessellatingHeckler
Mar 28 at 10:27












0






active

oldest

votes










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55387300%2fhow-can-get-command-return-commands-that-arent-really-commands%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes




Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.







Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55387300%2fhow-can-get-command-return-commands-that-arent-really-commands%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현