Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 00:01
    xtqqczze synchronize #13333
  • 00:01
    xtqqczze commented #13333
  • Oct 21 22:54
    PaulHigin assigned #13830
  • Oct 21 22:54
    PaulHigin labeled #13830
  • Oct 21 22:54
    PaulHigin labeled #13830
  • Oct 21 22:54
    PaulHigin opened #13830
  • Oct 21 22:16
    SteveL-MSFT commented #8958
  • Oct 21 22:07
    SteveL-MSFT labeled #8958
  • Oct 21 22:07
    SteveL-MSFT unlabeled #8958
  • Oct 21 22:07
    SteveL-MSFT commented #8958
  • Oct 21 21:48
    unfurl-links[bot] commented #6724
  • Oct 21 21:48
    aolszowka commented #6724
  • Oct 21 20:46
    cveld commented #6745
  • Oct 21 20:24

    rjmholt on master

    Update README and metadata.json… (compare)

  • Oct 21 20:24
    rjmholt closed #13821
  • Oct 21 20:10
    mkswd synchronize #13804
  • Oct 21 20:09
    mkswd commented #13806
  • Oct 21 20:08
    mkswd closed #13806
  • Oct 21 20:06
    msftbot[bot] unlabeled #13806
  • Oct 21 20:06
    mkswd synchronize #13806
matrixbot
@matrixbot
Celmor even though that file would shop up fine in most editors with the unprintable characters hidden it wouldn't be possible to execute it as a script for example
Mochtar van de Griendt
@Aprazeth
@cbj4074 One of the many possible reasons why that may happen is due to encoding settings (OEM-457 or UTF-8 for example, regional settings, etc.) Also in PS version 2 (yes, I'm that old apparently... xD ) some of the ConvertTo-* cmdlets had their own little quirks, which is why I usually used the HTML variant, and then converted that back to whatever I needed (yes, the joy of that isn't lost on me) There might also be weird quirk in mysqldump.exe, try seeing if there is a newer version or updates for that. In short, my recommendation always is: never ever ever mess around with the encoding and/or regional settings, and make absolutely sure that your servers are all running the exact same settings for them. Save yourself from that headache and a half :-P
@matrixbot Celmor - there is something called Start-Transcript (see: https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.host/start-transcript?view=powershell-7) that will allow you to output and save all the commands entered into a file. I do recommend opening that with either Wordpad or notepad++ etc. as Windows notepad tends to get the linebreaks wrong :)
Merrick
@omgMerrickD
Is there a particular reason why a lot of the help files in Powershell 7 don't show the entirety of the full help page that you see in Powershell 5 when using Get-Help <cmdlet> -Full ?
Mochtar van de Griendt
@Aprazeth
@omgMerrickD Did you try running Update-Help ?
Brent Arias
@brentarias

Hey all. When I do this:

PS C:\repos\SearchAgent3\PlatformConnect> $List = gci . -Recurse | Where-Object Name -match 'Connector.csproj$' | select FullName; foreach ($item in $List){echo $item}

I get this result:

FullName
--------
C:\repos\SearchAgent3\PlatformConnect\AzureBlobConnector\AzureBlobConnector.csproj
C:\repos\SearchAgent3\PlatformConnect\FileSystemConnector\FileSystemConnector.csproj

How do I get the same result with the "FullName" header and underscore being printed?

Brent Arias
@brentarias
...aha! I think -ExpandProperty on the select command is my friend!
Ben Johnson
@cbj4074
@Aprazeth Thanks for taking a look, re: :point_up: September 26, 2020 3:44 AM . Given that the problem doesn't occur in cmd.exe, wouldn't the problem be outside the scope of the mysqldump.exe executable, though (hence, upgrading MySQL seems unlikely to help)? It seems like your other suggestion re: encoding is more likely, but I still don't know how to fix it, especially if tinkering with the encoding is a no-no. :)
Arnas Kučinskas
@Arnas-Kucinskas
Hello, is it possible to extract a function from higher ver powershell and use it on lower one without upgrading it?
Since rebooting servers to upgrade psversion would be problematic.
Mochtar van de Griendt
@Aprazeth
@cbj4074 What you could try to do is see what encoding (code page as I recall ... correct me if I'm wrong here) is set in both CMD as well as PowerShell. If they don't match, well there's your cause - and solution. I remember a similar situation where the DB showed a name (yeay for special characters!) correctly, in PS it showed correctly, but as soon as I exported it to a CSV, HTML, or even plain text, it would mess up. The solution was setting the char map to a specific variant, then exporting the data and at that point it came out correctly. Pain in the rear-side to figure out and it was still finnicky as can be :-|
@cbj4074 It was something with chcp (see https://ss64.com/nt/chcp.html and https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/chcp ) if memory serves me right :-)
Mochtar van de Griendt
@Aprazeth
@Arnas-Kucinskas In general, no - you can't extract a function from a higher/newer version of PowerShell and use it on a lower version. At least, depending on whether you are referring to Windows PowerShell (which I'll assume you are since you are talking about reboots) You >could< try to recreate the function yourself (I've had to 'recreate' Invoke-Webpage in PowerShell 2 more times then I care to remember in PowerShell 2...) but it'll be a mixed bag. The reason why it -in general- may not work is that newer versions of Windows PowerShell came bundled with a newer WMF (Windows Management Framework) Some of that new functionality requires that new WMF version.
Arnas Kučinskas
@Arnas-Kucinskas
I see, thanks
Mochtar van de Griendt
@Aprazeth
@Arnas-Kucinskas just as a FYI - Windows PowerShell updates can be deployed as part of your Microsoft / Windows updates - so the next time the machines get their security updates, you can tag that along (be sure you test it first on a non-production machine, have backups etc. - usual disclaimers apply :) )
matrixbot
@matrixbot
Will Pittenger I have Powershell 7 64-bit 7.0.3 installed on a Windows 10 Pro system. It's missing most of it's help files. Powershell 2.0, which came with the system, shows plenty of help files. My laptop doesn't have this problem. What can I do to fix the problem?
Mochtar van de Griendt
@Aprazeth
@matrixbot Will Pittenger - try running in an elevated PowerShell console Update-Help.
matrixbot
@matrixbot
Will Pittenger I always do that.
Will Pittenger Mochtar van de Griendt (Gitter): The problem was solved by adding -scope AllUsers.
Oisin Grehan
@oising
@matrixbot You are probably not using UAC, and have a separate admin account, correct?
This would explain why update-help requires allusers -- the majority of people (using UAC) would not be switching users to elevate, so currentuser scope is fine.
JRLRJ
@jrlilly
Hey everyone, we ran into a bit of a mystery earlier today with a mac user running one of our scripts. Turns out it's PowerShell/PowerShell#8702 that's causing the issue. The fact this bug totally destroys binary files in a way that is a workaround for how pipes work in powershell seems pretty critical. Is there a list of known platform specific issues that I can read over? I'd like to be able to evaluate if using powershell cross platform will be a good idea moving forward.
seanrl
@seanrl
I have a consistent issue with Powershell that involves Enterprise Network Drives. My company has a dozen Network Drives that are mapped to local drives on our desktops by IT, per policy. Normally, that is fine, but when the desktop is off network (not on the VPN), Powershell hangs upon opening. I'm pretty sure its due to timeouts during the Get-PSDrive phase of Powershell's bootup, and I've seen recommendations that say to just disconnect the network drives. However, that is not only against enterprise policy, it is also highly impractical to have to discon/recon every time I want to use Powershell off the VPN. Couldn't the Get-PSDrive call be made on a background thread, for all drives other than C:/?
Just for clarification, when I say hangs, I mean 15+ minutes
Ingo Karstein
@ikarstein
Hello! I'm developing a cmdlet in C# (.net core). The cmdlet has a parameter that should accept some different types of objects. - In SharePoint PowerShell this is done with something like this: class SPAlternateUrlPipeBind in cmdlet "Set-SPAlternateUrl" (https://docs.microsoft.com/en-us/powershell/module/sharepoint-server/set-spalternateurl?view=sharepoint-ps)
I cannot figure out how to register type conversation between multiple types. I tried to create a constructor for each accepted type but it does not work.
DEBUG: ParameterBinding Information: 0 : BIND POSITIONAL cmd line args [Start-MyJob]
DEBUG: ParameterBinding Information: 0 :     BIND arg [JobInfo] to parameter [Job]
DEBUG: ParameterBinding Information: 0 :         BIND arg [System.Collections.Generic.List`1[JobInfo]] to param [Job] SKIPPED
DEBUG: ParameterBinding Information: 0 :     BIND arg [JobInfo] to parameter [Job]
DEBUG: ParameterBinding Information: 0 :         COERCE arg to [JobBinding]
DEBUG: ParameterBinding Information: 0 :             Trying to convert argument value from System.Management.Automation.PSObject to JobBinding
DEBUG: ParameterBinderBase Information: 0 :  WriteLine               argument is PSObject with BaseObject as IList
DEBUG: ParameterBinding Information: 0 :             ERROR: ERROR: COERCE FAILED: arg [JobInfo] could not be converted to the parameter type [JobBinding]
Ingo Karstein
@ikarstein
okay... it's a problem with the parameter value when calling the cmdlet. the real object is encapsulated in a generic list object.
Joel Sallow (/u/ta11ow)
@vexx32
if the parameter should accept multiple types, you'd need to set the parameter type as PSObject
seanrl
@seanrl
For additional clarification on the ps hanging issue, after waiting an 1+ hour on this one, I got "Attempting to perform the InitializeDefaultDrives operation on the 'FileSystem' provider failed."
However, its still hung
Ben Johnson
@cbj4074

@Aprazeth Thanks again for the continued assistance! chcp returns 437 in both cmd.exe and Powershell, which, according to the link you provided, represents United States, which is where I am.

But then I found https://stackoverflow.com/a/17177904 , which, at the very bottom, essentially reiterates your position on the matter, which is that it's either a nuance/bug of the executable (in this case, mysqldump.exe), or a chcp issue. Given that we know it's not the latter, I took a closer look at the executable and found this in the manual:

image.png

Certainly sounds related! I'm going to give that a shot.

Ingo Karstein
@ikarstein

if the parameter should accept multiple types, you'd need to set the parameter type as PSObject

No. Thats not required. I have a "binding" class that has a constructor for all required data types. The problem was the input object which was encapsulated in a collection (with a single item).

Joel Sallow (/u/ta11ow)
@vexx32
ah, you might want to use a transformation attribute for that tbh, but either works
the parameter type itself is not List<>?
Mochtar van de Griendt
@Aprazeth
@cbj4074 Not a problem - hope that indeed works out for you :)
@seanrl That's very odd. I have network drives mapped, and when disconnected from the network I do not get those massive delays in opening PS. Are there perhaps any kind of scripts etc. that are started at PowerShell start? Because that does not sound normal - at all. Otherwise, maybe look at cached files/folders (or whatever it is called nowadays)
matrixbot
@matrixbot

Will Pittenger I have the function shown below:

function sum-TimeSpans
{
param
(
[string[]]
[Parameter(ValueFromRemainingArguments)]
$list
)
$tsTotal = New-Object "System.Object"

foreach($strCurChild in $list)
{
$tsCurChild = [System.TimeSpan]::Parse($strCurChild)
$tsTotal = ($tsTotal) + ($tsCurChild)
}

return $tsTotal
}
The line that parses the time span behaves in a way I don't understand. If that line doesn't store the result in $tsCurChild, it can compute it. If I take that line and run it outside the function, but including the assignment, it also works. But as shown, it fails. What am I doing wrong?

Will Pittenger I wrote this as measure-object doesn't work on timespans.
matrixbot
@matrixbot

Will Pittenger * I have the function shown below:

function sum-TimeSpans
{
param
(
[string[]]
[Parameter(ValueFromRemainingArguments)]
$list
)
$tsTotal = New-Object "System.Object"

foreach($strCurChild in $list)
{
$tsCurChild = [System.TimeSpan]::Parse($strCurChild)
$tsTotal = ($tsTotal) + ($tsCurChild)
}

return $tsTotal
}
The line that parses the time span behaves in a way I don't understand. If that line doesn't store the result in $tsCurChild, it can compute it. If I take that line and run it outside the function, but including the assignment, it also works. But as shown, it fails. What am I doing wrong?

Will Pittenger * I have the function shown below:

function sum-TimeSpans
{
param
(
[string[]]
[Parameter(ValueFromRemainingArguments)]
$list
)
$tsTotal = New-Object "System.Object"

foreach($strCurChild in $list)
{
$tsCurChild = [System.TimeSpan]::Parse($strCurChild)
$tsTotal = ($tsTotal) + ($tsCurChild)
}

return $tsTotal
}

The line that parses the time span behaves in a way I don't understand. If that line doesn't store the result in $tsCurChild, it can compute it. If I take that line and run it outside the function, but including the assignment, it also works. But as shown, it fails. What am I doing wrong?

matrixbot
@matrixbot

Will Pittenger * I have the function shown below:

function sum-TimeSpans
>> {
>>   param
>>   (
>>     [string[]]
>>     [Parameter(ValueFromRemainingArguments)]
>>     $list
>>   )
>>   $tsTotal = New-Object "System.TimeSpan"
>>
>>   foreach($strCurChild in $list)
>>   {
>>     $tsCurChild = [System.TimeSpan]::Parse($strCurChild)
>>     $tsTotal += ($tsCurChild)
>>   }
>>
>>   return $tsTotal
>> }

The line that parses the time span behaves in a way I don't understand. If that line doesn't store the result in $tsCurChild, it can compute it. If I take that line and run it outside the function, but including the assignment, it also works. But as shown, it fails. What am I doing wrong?

Will Pittenger * I have the function shown below:

function sum-TimeSpans
{
   param
   (
     [string[]]
     [Parameter(ValueFromRemainingArguments)]
     $list
   )
   $tsTotal = New-Object "System.TimeSpan"

   foreach($strCurChild in $list)
   {
     $tsCurChild = [System.TimeSpan]::Parse($strCurChild)
     $tsTotal += ($tsCurChild)
   }

   return $tsTotal
 }

```

The line that parses the time span behaves in a way I don't understand. If that line doesn't store the result in $tsCurChild, it can compute it. If I take that line and run it outside the function, but including the assignment, it also works. But as shown, it fails. What am I doing wrong?

Will Pittenger * I have the function shown below:

function sum-TimeSpans
{
   param
   (
     [string[]]
     [Parameter(ValueFromRemainingArguments)]
     $list
   )
   $tsTotal = New-Object "System.TimeSpan"

   foreach($strCurChild in $list)
   {
     $tsCurChild = [System.TimeSpan]::Parse($strCurChild)
     $tsTotal += ($tsCurChild)
   }

   return $tsTotal
 }

The line that parses the time span behaves in a way I don't understand. If that line doesn't store the result in $tsCurChild, it can compute it. If I take that line and run it outside the function, but including the assignment, it also works. But as shown, it fails. What am I doing wrong?

matrixbot
@matrixbot
Will Pittenger Strangely, it seems to return the expected value.
Will Pittenger Or at least it does when I skip $tsCurChild and add the return value from Parse into $tsTotal.
Will Pittenger Still throws exceptions each time I call Parse though.
Will Pittenger I currently have
function sum-TimeSpans
 {
   param
   (
     [string[]]
     [Parameter(ValueFromRemainingArguments)]
     $list
   )
   $tsTotal = New-Object "System.TimeSpan"

   foreach($strCurChild in $list)
   {
     $tsTotal += [System.TimeSpan]::Parse($strCurChild)
   }

   return $tsTotal
 }
matrixbot
@matrixbot
Will Pittenger It doesn't help that the error implies that the method `[System.TimeSpan]::Parse' isn't a valid time span. Is it complaining the object returned isn't valid or the parameter isn't valid?
Will Pittenger > Exception calling "Parse" with "1" argument(s): "String '[System.TimeSpan]::Parse' was not recognized as a valid TimeSpan."
matrixbot
@matrixbot
Will Pittenger Fixed. It was a bad call.