|
Powershell 7 Release Candidate is out
|
# ? Dec 17, 2019 14:36 |
|
|
# ? Jun 3, 2024 22:11 |
|
Is there a way to set the DateTime properties of a symlink (i.e. NOT the referenced file of one) in PowerShell? I know how to create, identify, and remove them but I can't update the properties of them. I have a feeling it's not possible, but figured I'd ask this here anyway.
|
# ? Dec 21, 2019 22:59 |
|
I might be missing something really obvious. I'm trying to install the Exchange Powershell V2 module using directions found here: https://docs.microsoft.com/en-us/po...iew=exchange-ps According to what I see, it says to run the following command from an elevated Powershell session (as Adminstrator) code:
Could not retrieve modules repository from 'https://github.com/psget/psget/raw/master/Directory.xml'. Status code: At C:\windows\system32\windowspowershell\v1.0\Modules\PsGet\PsGet.psm1:519 char:13 + throw "Could not retrieve modules repository from '$DirectoryUrl'. S ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : OperationStopped: (Could not retri.... Status code: :String) [], RuntimeException + FullyQualifiedErrorId : Could not retrieve modules repository from 'https://github.com/psget/psget/raw/master/Directory.xml'. Status code: If I try to get it form GitHub directly I get a line to copy: code:
What am I doing wrong?
|
# ? Dec 26, 2019 21:43 |
|
Cold on a Cob posted:Is there a way to set the DateTime properties of a symlink (i.e. NOT the referenced file of one) in PowerShell? I know how to create, identify, and remove them but I can't update the properties of them. I have a feeling it's not possible, but figured I'd ask this here anyway. No, symlinks do not have attributes and are simply designed to transparently redirect all write operations to the target path. CzarChasm posted:I might be missing something really obvious. I'm trying to install the Exchange Powershell V2 module using directions found here: https://docs.microsoft.com/en-us/po...iew=exchange-ps What version of PowerShell are you using (Just check $PSVersionTable)?
|
# ? Dec 27, 2019 08:58 |
|
Pile Of Garbage posted:No, symlinks do not have attributes and are simply designed to transparently redirect all write operations to the target path. They do have the attributes I'm interested in being able to change, but it appears there is no way to change them in PS - LastWriteTime for example: code:
code:
code:
Cold on a Cob fucked around with this message at 15:21 on Dec 27, 2019 |
# ? Dec 27, 2019 15:13 |
|
Well poo poo. That's pretty wild. Intuitively I would have thought NTFS symlinks would transparently redirect all writes including those to attributes. I suspect that it's possible in WSL due to the weird POSIX emulation or whatever it does. Willing to admit that I'm wrong here and not 100% sure.
|
# ? Dec 27, 2019 15:35 |
|
I think the API for symlinks on Windows just isn't there because nobody was using them until extremely recently (because you had to be admin). You could try filing a bug, but .net would probably have to get it first before they can add it to powershell (right now it appears you have to use pinvoke and there's no native way to do it in .net).
|
# ? Dec 27, 2019 15:39 |
|
Pile Of Garbage posted:Well poo poo. That's pretty wild. Intuitively I would have thought NTFS symlinks would transparently redirect all writes including those to attributes. I suspect that it's possible in WSL due to the weird POSIX emulation or whatever it does. Willing to admit that I'm wrong here and not 100% sure. Yeah I was worried that was the case until I tried touch with WSL2. I also did some more reading and with Win32 you actually have to dereference them manually. I'm happy C# and PS don't make us do that and it's a pretty small edge case so no big deal. I was actually trying to fully recreate touch in PS on a lark. I guess I'll change -h to not dereference symlinks by skipping them entirely. Still better than all the touch implementations I've seen in the wild.
|
# ? Dec 27, 2019 15:50 |
|
mystes posted:I think the API for symlinks on Windows just isn't there because nobody was using them until extremely recently (because you had to be admin). You could try filing a bug, but .net would probably have to get it first before they can add it to powershell (right now it appears you have to use pinvoke and there's no native way to do it in .net). Anecdotally I've used symlinks in the past with PowerShell by invoking mklink as an insane means of bypassing the MAX_PATH limit. It was a script meant to copy files out of garbage locations into more reasonable locations (We were ingesting files from SMB shares into a DMS, said DMS couldn't deal with an arbitrary set of characters or source-paths over MAX_PATH). Iterate through a CSV, if source path is over MAX_PATH then just nest symlinks until it isn't and then replace characters on the copy . Sounds crazy but it fuckin worked. Of course I stressed to them that it was a one-off thing and should never be used again... Edit: it's actually surprising how quickly symlinks can be created/destroyed. My blocking logging to console of said creation/destruction actually slowed it down... Pile Of Garbage fucked around with this message at 16:04 on Dec 27, 2019 |
# ? Dec 27, 2019 15:58 |
|
Pile Of Garbage posted:What version of PowerShell are you using (Just check $PSVersionTable)? I'm on 4.0, thought I was on 5. I'll do the update to 5 after the weekend and see if that fixes it.
|
# ? Dec 27, 2019 18:16 |
|
CzarChasm posted:I'm on 4.0, thought I was on 5. I'll do the update to 5 after the weekend and see if that fixes it. Try code:
Inspector_666 fucked around with this message at 18:25 on Dec 27, 2019 |
# ? Dec 27, 2019 18:23 |
|
That said the doco indicates that only v5.0/5.1 is supported so maybe just upgrade and not try to get it going on an unsupported version.
|
# ? Dec 27, 2019 19:29 |
|
I mean yeah, update PShell regardless, but even in 5.1 I have to use the piped command.
|
# ? Dec 27, 2019 19:51 |
|
I have a simple PS using HtmlAgilityPack doing web scraping. This works as expected:code:
code:
code:
What stupid thing am I overlooking?
|
# ? Jan 1, 2020 00:27 |
|
Pile Of Garbage posted:Well poo poo. That's pretty wild. Intuitively I would have thought NTFS symlinks would transparently redirect all writes including those to attributes. I suspect that it's possible in WSL due to the weird POSIX emulation or whatever it does. Willing to admit that I'm wrong here and not 100% sure. A lot of Unix commands have an absurd amount of parameters for how they should handle symlinks this time.
|
# ? Jan 2, 2020 03:27 |
|
Secx posted:I have a simple PS using HtmlAgilityPack doing web scraping. This works as expected: The Cannot index into a null array error occurs when you try to use the array index selector ([0]) on a null object. e.g. code:
code:
|
# ? Jan 2, 2020 05:44 |
|
Anyone ever encounter this? I'm trying to run a stored procedure on a PostgreSQL database (AWS Redshift) via PowerShell and it's giving me the weirdest error.code:
code:
|
# ? Jan 6, 2020 18:15 |
|
PierreTheMime posted:Anyone ever encounter this? I'm trying to run a stored procedure on a PostgreSQL database (AWS Redshift) via PowerShell and it's giving me the weirdest error. Does the sproc have required parameters? How about does it return a result set? Both of those could be issues E: I'm on my phone but could your command type need to be set to stored procedure or something?
|
# ? Jan 6, 2020 18:43 |
|
Nth Doctor posted:Does the sproc have required parameters? It doesn't have any parameters, it's supposed to create a temporary table elsewhere to be queried. The PostgreSQL documentation (https://www.postgresql.org/docs/12/errcodes-appendix.html) shows 42809 is "wrong_object_type" but I'm not quite sure how else I should handle this? I've tried using the normal query-like command (queries work, by the way) and specifying the commandtype as procedure ($DBCmd.CommandType = [System.Data.CommandType]::StoredProcedure) with no change.
|
# ? Jan 6, 2020 18:57 |
|
PierreTheMime posted:It doesn't have any parameters, it's supposed to create a temporary table elsewhere to be queried. Your problem has been bothering me for the past couple of days and I did some digging. Your command text may be the problem here since you're using an ODBC command to execute a sproc instead of an ADO command object. Here's the object documentation: https://docs.microsoft.com/en-us/dotnet/api/system.data.odbc.odbccommand.commandtext?view=netframework-4.8 OdbcCommand.CommandText Property Documentation posted:A procedure is an executable object stored at the data source. Generally, it is one or more SQL statements that have been precompiled. The escape sequence for calling a procedure is Instead of code:
code:
Guess who used to maintain my company's ODBC platform.
|
# ? Jan 8, 2020 17:18 |
|
Nth Doctor posted:ODBC fun code:
Edit: I've been formatting CSV reports all day--is this a decent way to get a MMM-formatted list of months in the proper monthly (Jan-Dec) order from an array of Strings or is there a simpler way to go about it? code:
PierreTheMime fucked around with this message at 21:16 on Jan 8, 2020 |
# ? Jan 8, 2020 18:18 |
|
PierreTheMime posted:Edit: Are you looking to produce a sorted list of all month names, or just the ones that appear in the CSV? If it's the former, code:
code:
If it's the latter, this is the way I like best so far, but I feel like there's probably a better way. code:
Toast Museum fucked around with this message at 03:04 on Jan 9, 2020 |
# ? Jan 9, 2020 01:09 |
|
The ask is based around sorting small arrays of M/d/yyyy date strings like @(“1/31/2020”,”2/1/2020”) and appending the summary of the months in MMM format to the end of a filename in the correct order using a join. So if all the dates are in January, it’s just appending “Jan”, but in the the two month example above it would be “Jan-Feb”. It’s one of those things that’s pretty simple to do, but I’m always interested in the “right” way.
|
# ? Jan 9, 2020 01:34 |
|
PierreTheMime posted:The ask is based around sorting small arrays of M/d/yyyy date strings like @(“1/31/2020”,”2/1/2020”) and appending the summary of the months in MMM format to the end of a filename in the correct order using a join. So if all the dates are in January, it’s just appending “Jan”, but in the the two month example above it would be “Jan-Feb”. Gotcha. I'm not ready to claim that it's the best or right way, but here's a function to return the string you're after. code:
|
# ? Jan 9, 2020 03:03 |
|
PierreTheMime posted:The ask is based around sorting small arrays of M/d/yyyy date strings like @(“1/31/2020”,”2/1/2020”) and appending the summary of the months in MMM format to the end of a filename in the correct order using a join. So if all the dates are in January, it’s just appending “Jan”, but in the the two month example above it would be “Jan-Feb”. I would think pulling and formatting the first and last date in ascending order to just pull the Month part should get you want you're looking for pretty simply. Granted it complicates the single month scenario so maybe not the best idea after all.
|
# ? Jan 9, 2020 03:20 |
|
I'm trying to automate some IIS stuff and I'm getting stuck trying to assign an SSL certificate to an HTTPS binding. I'm using the following command:code:
The error I'm getting is: A specified logon session does not exist. It may already have been terminated.
|
# ? Jan 10, 2020 00:33 |
|
a hot gujju bhabhi posted:I'm trying to automate some IIS stuff and I'm getting stuck trying to assign an SSL certificate to an HTTPS binding. I'm using the following command: Try this: code:
|
# ? Jan 11, 2020 07:15 |
|
Is there any way to take something icky like a server IP list in a text file and make it into json?
|
# ? Jan 13, 2020 00:14 |
|
Woof Blitzer posted:Is there any way to take something icky like a server IP list in a text file and make it into json? code:
|
# ? Jan 13, 2020 00:47 |
|
PowerShell 7 RC 2 is out
|
# ? Jan 17, 2020 19:30 |
|
I've been hacking away at some logging code to make it easier to send our logs to our syslog servers like the majority of our infra does…code:
I don't get it. Only Write-Debug throws an exception and only when in a switch statement.
|
# ? Jan 22, 2020 16:35 |
|
The "?" character is special in Powershell. Try replacing the "???" string with "OHSHIT" instead and see if you get a different result.
|
# ? Jan 22, 2020 17:41 |
|
It's an actual variable in the actual code, I just did some redacting. It shows the exact same exception with "foo".
|
# ? Jan 22, 2020 17:54 |
|
Antigravitas posted:I've been hacking away at some logging code to make it easier to send our logs to our syslog servers like the majority of our infra does When you say that only Write-Debug does it, do you mean that it doesn't happen with Write-Error, Write-Verbose, etc.? Maybe a scope issue? Switch statement scriptblocks have their own scope. The most granular way I know of to specify variable scope is with Get-Variable
|
# ? Jan 22, 2020 18:08 |
|
Write-Warning, Write-Verbose, Write-Error don't show the behaviour, it's literally only Write-Debug. I suspected scoping issues first but a string literal is the most in-scope I can think of.
|
# ? Jan 22, 2020 18:42 |
|
Ah, poo poo, I forgot the part where you said that it does the same with a string. So much for that idea.
|
# ? Jan 22, 2020 18:50 |
|
Any chance it's an encoding issue?
|
# ? Jan 22, 2020 19:00 |
|
Does the script do something weird with scoping $DebugPreference?
|
# ? Jan 22, 2020 21:56 |
|
Antigravitas posted:I've been hacking away at some logging code to make it easier to send our logs to our syslog servers like the majority of our infra does… Can you post the code?
|
# ? Jan 23, 2020 01:47 |
|
|
# ? Jun 3, 2024 22:11 |
|
Jethro posted:Does the script do something weird with scoping $DebugPreference? Bingo. It's a new day, just got into the office, did a git diff on a lark, and found this piece of code within the module: code:
code:
|
# ? Jan 23, 2020 09:57 |