This is a continuation of a previous post, but I thought I’d start it clean and explain what I’ve found.
OK, riddle me this Batman.
If I run the following bit of code (I’ve temporarily commented out the -ErrorAction parameter to see what results I would get):
$Name = '*' $Module = '*' $Computer = 'localhost' $GCScriptBlock = { $ConfirmImpactLevelExpr = @{ Name = 'ConfirmImpactLevel'; Expression = {$_.ImplementingType.GetCustomAttributes($True).ConfirmImpact} } Get-Command -Name Stop-* -CommandType Cmdlet -Module $Using:Module | Select-Object -Property Name,CommandType,ModuleName,$ConfirmImpactLevelExpr } $ImpactLevelData = Invoke-Command -ComputerName $Computer -ScriptBlock $GCScriptBlock #-ErrorAction Stop
I get the below errors on just these two cmdlets:
The term ‘Add-ClusteriSCSITargetServerRole’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was
included, verify that the path is correct and try again.
+ CategoryInfo : ObjectNotFound: (Add-ClusteriSCSITargetServerRole:String) [Get-Command], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException,Microsoft.PowerShell.Commands.GetCommandCommand
+ PSComputerName : localhost
The term ‘Block-GPInheritance’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included,
verify that the path is correct and try again.
+ CategoryInfo : ObjectNotFound: (Block-GPInheritance:String) [Get-Command], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException,Microsoft.PowerShell.Commands.GetCommandCommand
+ PSComputerName : localhost
Ok, now for the strange part. I focused on the Add-ClusteriSCSITargetServerRole cmdlet. Here is what I found.
Note: Keep in mind, I’m doing this all on the same machine, same ISE.
- No matter what combination of parameters & wildcards I used, either the same error from above occurred when I tried to use Get-Command to look for the Add-ClusteriSCSITargetServerRole cmdlet, or the cmdlet was not in the resulting list.
–Commands I tried:
a. First Set:
Get-Command -Name Add-ClusteriSCSITargetServerRole <--- Error occurred
Note: Same error occurred when I tried to do the following:
Invoke-Command -ComputerName localhost -ScriptBlock {Get-Command -Name Add-ClusteriSCSITargetServerRole}
b. Second Set:
Get-Command -Name Add-* -Module IscsiTarget <--- I know this is the Module the cmdlet is a part of from my testing (See further down). CommandType Name Version Source ----------- ---- ------- ------ Cmdlet Add-IscsiVirtualDiskTargetMapping 2.0.0.0 IscsiTarget
Note: Same output occurred when I did the following:
Invoke-Command -ComputerName localhost -ScriptBlock {Get-Command -Name Add-* -Module IscsiTarget}
c. Third Set:
Get-Command -Name * -CommandType Cmdlet -Module IscsiTarget <--- The cmdlet was not in the list.
Note: Same output occurred when I did the following:
Invoke-Command -ComputerName localhost -ScriptBlock {Get-Command -Name * -CommandType Cmdlet -Module IscsiTarget}
d. Etc…
Now, if I used Invoke-Command in combination with wildcards(i.e. * OR Add-*), the cmdlet showed up in the list. So, the following commands listed the command. None of the below Get-Command commands listed the Add-ClusteriSCSITargetServerRole outside Invoke-Command.
- First One:
Invoke-Command -ComputerName localhost -ScriptBlock {Get-Command -Name * -CommandType Cmdlet} CommandType Name Version Source PSComputerName ----------- ---- ------- ------ -------------- Cmdlet Add-ClusteriSCSITargetServerRole 2.0.0.0 IscsiTarget localhost
- Second One:
Invoke-Command -ComputerName localhost -ScriptBlock {Get-Command -Name * -CommandType Cmdlet -Module *} CommandType Name Version Source PSComputerName ----------- ---- ------- ------ -------------- Cmdlet Add-ClusteriSCSITargetServerRole 2.0.0.0 IscsiTarget localhost
Hope someone has an idea what's going on. This is driving me nuts.