Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Installation Process broken or needs some documentation #14

Open
DanRobinsonHPE opened this issue Dec 6, 2021 · 11 comments
Open

Installation Process broken or needs some documentation #14

DanRobinsonHPE opened this issue Dec 6, 2021 · 11 comments

Comments

@DanRobinsonHPE
Copy link

PS C:\WINDOWS\system32> Install-Module -Name PoshNmap
PS C:\WINDOWS\system32> Invoke-Nmap
Invoke-Nmap : The term 'Invoke-Nmap' 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.
At line:1 char:1
+ Invoke-Nmap
+ ~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Invoke-Nmap:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

PS C:\WINDOWS\system32>
PS C:\WINDOWS\system32> Get-Host | Select-Object Version

Version
-------
5.1.19041.1320

PS C:\WINDOWS\system32> Get-InstalledModule

Version              Name                                Repository           Description
-------              ----                                ----------           -----------
1.4.3                PackageManagement                   PSGallery            PackageManagement (a.k.a. One...
2.2                  PowerShellGet                       PSGallery            PowerShell module with comman...
1.0.6.19             SnippetPx                           PSGallery            The SnippetPx module enhances...
2.2                  Posh-SSH                            PSGallery            Provide SSH and SCP functiona...
0.6.1                PoshNmap                            PSGallery            A wrapper for NMAP Network Di...
@DanRobinsonHPE
Copy link
Author

I see now there is 1 line i missed.
"Must have nmap already installed"
Would the above error have been caused because I didn't?

@JustinGrote
Copy link
Owner

@DanRobinsonHPE confirmed looks like there is an issue on 5.1, it works just fine on Powershell 7, looks to be a packaging issue with the newest version.
image

@bust4rhymes
Copy link

In powershell 7.2.2 its not working either:

PS C:\Windows\System32> Install-Module -Name PoshNmap

Untrusted repository
You are installing the modules from an untrusted repository. If you trust this repository, change its
InstallationPolicy value by running the Set-PSRepository cmdlet. Are you sure you want to install the modules from
'PSGallery'?
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "N"): A
PS C:\Windows\System32> Invoke-Nmap
Get-Command: C:\Program Files\WindowsPowerShell\Modules\poshnmap\0.6.1\Private\StartNmap.ps1:8
Line |
8 | $nmapexe = (Get-Command nmap).path
| ~~~~~~~~~~~~~~~~
| The term 'nmap' is not recognized as a name of a cmdlet, function, script file, or executable program.
| Check the spelling of the name, or if a path was included, verify that the path is correct and try
| again.

InvalidOperation: C:\Program Files\WindowsPowerShell\Modules\poshnmap\0.6.1\Private\StartNmap.ps1:9
Line |
9 | & "$nmapexe" $argumentList $computerName
| ~~~~~~~~~~
| The expression after '&' in a pipeline element produced an object that was not valid. It must result
| in a command name, a script block, or a CommandInfo object.

PS C:\Windows\System32> Get-Host | Select-Object Version

Version

7.2.2

PS C:\Windows\System32> Get-InstalledModule
PS C:\Windows\System32>

@JustinGrote
Copy link
Owner

@bust4rhymes this module does not install nmap for you, you have to supply it.

@patrickenfuego
Copy link

@JustinGrote it looks like you have an extra PoshNmap in the load path on line 20 of the manifest file. It should go $PSScriptRoot\lib\Newtonsoft.Json-net40-client.dll. I removed it and the module loaded as expected.

@securatodd
Copy link

@JustinGrote it looks like you have an extra PoshNmap in the load path on line 20 of the manifest file. It should go $PSScriptRoot\lib\Newtonsoft.Json-net40-client.dll. I removed it and the module loaded as expected.

Found the same - and now I run into

PS C:\windows\system32> Invoke-Nmap www.google.com
ConvertFromXml : Method invocation failed because [Newtonsoft.Json.JsonConvert] does not contain a method named
'SerializeXmlNode'.
At C:\Program Files\WindowsPowerShell\Modules\PoshNMap\0.6.1\Public\ConvertFrom-NmapXML.ps1:41 char:26

  • ... (ConvertFromXml ([xml]$hostEntry).host).host | ...
  •                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidOperation: (:) [ConvertFromXML], RuntimeException
    • FullyQualifiedErrorId : MethodNotFound,ConvertFromXML

Trying some work arounds got it to work eventually - now I get

PS> $var = @(Invoke-NMap www.google.com '-p 1-65535 -T4 -A -v')
ForEach-Object: C:\Program Files\WindowsPowerShell\Modules\PoshNmap\0.6.1\Private\FormatPoshNmapHost.ps1:43:32
Line |
43 | $hostnode.ports.port | foreach-object {
| ~~~~~~~~~~~~~~~~
| Index operation failed; the array index evaluated to null.

@JustinGrote
Copy link
Owner

@securatodd what version of Powershell are you running? It's only meant for 5.1+

@securatodd
Copy link

securatodd commented Jun 8, 2022

@securatodd what version of Powershell are you running? It's only meant for 5.1+

Current Version I am running in is 5.1.17763.2867

@JustinGrote
Copy link
Owner

Thanks, I'll try to investigate when I get time but unfortunately I have very little bandwidth for my community repos at the moment. Sorry, it is what it is :/

@GeorgeBroughton
Copy link

@DanRobinsonHPE confirmed looks like there is an issue on 5.1, it works just fine on Powershell 7, looks to be a packaging issue with the newest version. image

i'm having the same problem with Powershell 7.4.0

> Install-Module -Name PoshNmap
Untrusted repository
You are installing the modules from an untrusted repository. If you trust this repository, change its InstallationPolicy value by running the Set-PSRepository cmdlet. Are you sure you want to install the modules from 
'PSGallery'?
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "N"): a

> get-installedmodule

Version              Name                                Repository           Description
-------              ----                                ----------           -----------
0.6.1                PoshNmap                            PSGallery            A wrapper for NMAP Network Discovery

> invoke-nmap google.com
invoke-nmap: The term 'invoke-nmap' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

In the latest version did you export/alias the functions properly?
I'm going to go check.

@JustinGrote
Copy link
Owner

Works for me on 7.4, fresh install.
image

Do ipmo poshnmap -passthru |% exportedcommands to verify

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants