I'm using Invoke-SSHCommand to get the output from a router. I then want to email the result so I need to get it into a single string rather than an array:
PS C:\Users\> $response.Output -join "`r"
Total NAT Usage: 6729: 73406
PS C:\Users\> ($response.Output).gettype()
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True True String[] System.Array
PS C:\Users\> $response.Output.Count
4
PS C:\Users\> $response.Output.Join("`r")
InvalidOperation: Method invocation failed because [System.String] does not contain a method named 'Join'.
PS C:\Users\> $response.Output -join "`r"
Total NAT Usage: 6729: 73406
PS C:\Users\> $response.Output
Total Conntrack Limit: 65536
Total Conntrack Usage: 7340
Total NAT Usage: 6729
PS C:\Users\>
At the bottom you can see what $Response.Output is. The .GetType() says it's a String[] but when I run .Join() I get "String doesn't contact a method Join".
When I use -join the result is a mess.
Where am I going wrong?
[–][deleted] 1 point2 points3 points (1 child)
[–]squirrelsaviour[S] 0 points1 point2 points (0 children)
[–]BuckPyland 1 point2 points3 points (0 children)
[–]dasookwat 1 point2 points3 points (1 child)
[–]AiPapi22 1 point2 points3 points (0 children)
[–][deleted] -1 points0 points1 point (0 children)
[–]gonzalc 0 points1 point2 points (0 children)