|
What do you all use for version control? I've been trying to set up Git at work, and either Git is obtuse, I'm dumb, or both. What I want is a repository that lives on an internal file share with the authoritative versions of those files actually stored there. I want something as close to seamless as possible for an ISE like VSCode (or whatever) to be pointed at that file share (repo, whatver) and natively edit those files with changes silently synced without having to muck around with the command line with every save. Our infrastructure is set up in such a way that scripts need to be ("need to be") locally edited on a variety of machines. Right now we use the ISE and frequently hear "wait a minute, this is the wrong file, I know I fixed this the other day, where is it" and queue the half hour of searching or re-coding. While testing, I managed to get VSCode doing that with a cloud hosted repo on VSTS, but cloud hosted won't work in production for a variety of reasons. So now I'm trying a bunch of variations of code:
Help?
|
# ? Sep 29, 2018 19:53 |
|
|
# ? May 15, 2024 03:26 |
|
Happiness Commando posted:What do you all use for version control? I've been trying to set up Git at work, and either Git is obtuse, I'm dumb, or both.
|
# ? Sep 29, 2018 20:12 |
|
Jesus gently caress I don't understand any of this. Using VS Code to sync which does a pull and then a push.code:
I can use a bare repo as my remote (cloning the repo locally and then committing and pushing to the remote) works. loving finally. But the files all live on my workstation, since it's a bare repo. OK. Make a bare repo, clone it to another folder on the server. Clone that other folder locally. Pull and push. Same loving error. What the gently caress.
|
# ? Oct 1, 2018 21:54 |
|
Happiness Commando posted:Jesus gently caress I don't understand any of this. Using VS Code to sync which does a pull and then a push. Also, you would probably be better off asking git related questions in the General Programming Questions thread rather than this one.
|
# ? Oct 1, 2018 23:14 |
|
There is actually a a git specific thread. It is fairly slow, but enough people have it bookmarked that questions get answered. The Fool fucked around with this message at 23:31 on Oct 1, 2018 |
# ? Oct 1, 2018 23:28 |
|
What's the best way to suppress error messages from non-Powershell object methods? I'm reading in an Excel file and them attempting to output each individual sheet as a CSV. It all works fine, it's just that some of my Excel workbooks don't have all of the sheets in them - at which point I get an ugly error message on screen. code:
code:
|
# ? Oct 4, 2018 14:28 |
|
Use try {} catch {} ?
|
# ? Oct 4, 2018 14:47 |
|
The Fool posted:Use try {} catch {} ? Or use -ErrorAction SilentlyContinue if you hate yourself and whoever has to maintain the script after you.
|
# ? Oct 4, 2018 16:52 |
|
The Fool posted:Use try {} catch {} ? This worked, thanks. New Yorp New Yorp posted:Or use -ErrorAction SilentlyContinue if you hate yourself and whoever has to maintain the script after you. This didn't work, because the method doesn't understand what -ErrorAction means - it's a ComObject method, not a native Powershell one.
|
# ? Oct 4, 2018 17:03 |
|
I'm trying to write a small powershell script that will go to active directory and return all records (users and distribution groups) and the boolean value of the attribute msExchRequireAuthToSendTo which will be either true, false, or not set. Unfortunately something is broken. All I have so far is code:
Even if that did work, I would have to run it three times to get a version for all three values. And even then, I don't know what the argument for neither true nor false would be. Is there some way to get just the account name or email address and the value of the attribute in a simple two column list? Is powershell the best way to go about this or is there a better way? I probably don't need to add that I'm new to powershell and don't have a lot of experience with it.
|
# ? Oct 4, 2018 17:54 |
|
I might be easier to just code:
|
# ? Oct 4, 2018 18:00 |
Do you need to get this for every user and group object in AD? In that case just use Get-ADObject to return all user and group objects under the relevant OU. Or even just globally. Sort and filter the results afterwards. Remember to use the -Properties parameter to specify which properties to fetch the values for. E:f,b
|
|
# ? Oct 4, 2018 18:03 |
|
CzarChasm posted:I'm trying to write a small powershell script that will go to active directory and return all records (users and distribution groups) and the boolean value of the attribute msExchRequireAuthToSendTo which will be either true, false, or not set. Get-Aduser won't return groups, you should use get-adobject. Following Inspector_666's advice, something like this should work: code:
|
# ? Oct 4, 2018 18:08 |
|
That works really well. Thank you very much for the help.
|
# ? Oct 4, 2018 19:44 |
|
Do people have thoughts on foreach vs ForEach-Object? Is one or the other more readable? Better performing? More powershelly? I prefer foreach because it reads better to me but that could be the last vestiges of Python being my native language. My coworker uses ForEach-Object and it looks kinda dirty and messy but piping does seem more in line with doing things the Powershell way.
|
# ? Oct 9, 2018 23:44 |
|
I prefer ForEach in scripts. I have used ForEach-Object in one liners, but generally if my one liners is starting to get that complicated I probably need to unpack it a bit.
|
# ? Oct 9, 2018 23:47 |
|
FISHMANPET posted:Do people have thoughts on foreach vs ForEach-Object? Is one or the other more readable? Better performing? More powershelly? code:
code:
code:
code:
code:
anthonypants fucked around with this message at 23:57 on Oct 9, 2018 |
# ? Oct 9, 2018 23:52 |
|
It depends on how far along in the code you need the context of the object. Like its been said, if its one line $_ isnt too bad but if its used in multiple places across forty lines of code its probably best it has a real name to avoid confusion. Edit: wow that apostrophe conversion sure is a thing huh Edit edit: I forgot to post earlier, has anyone had much experience with compounding variable values across recursion? For whatever reason passing a variable in, appending it, and then returning it lead to multiple repetitions of the same values in a way that struck me as odd. I instead ended up having it return an entirely new variable and appending that to the current variable. PierreTheMime fucked around with this message at 00:55 on Oct 10, 2018 |
# ? Oct 10, 2018 00:51 |
|
FISHMANPET posted:Do people have thoughts on foreach vs ForEach-Object? Is one or the other more readable? Better performing? More powershelly? For some reason, there's a performance difference between those two seemingly identical functions. https://blogs.technet.microsoft.com/heyscriptingguy/2014/07/08/getting-to-know-foreach-and-foreach-object/ code:
|
# ? Oct 10, 2018 04:47 |
|
sloshmonger posted:For some reason, there's a performance difference between those two seemingly identical functions.
|
# ? Oct 10, 2018 05:18 |
|
anthonypants posted:And the method is supposed to be even faster. PowerShell code:
ForEach_Statement: 7.292194ms ForEach_Method: 39.3125347ms
|
# ? Oct 10, 2018 14:29 |
|
PBS posted:ForEach-Object: 69.9019716ms anthonypants posted:And the method is supposed to be even faster. I had no idea the method even existed. Thanks for showing me that. I've usually gone with functions or statements. I guess you could say I'm not a... Method Man
|
# ? Oct 10, 2018 17:25 |
|
sloshmonger posted:I guess you could say I'm not a... Method Man That would be a "methodic" or a "methodist". I'd go with the religious one.
|
# ? Oct 10, 2018 18:55 |
|
Volguus posted:That would be a "methodic" or a "methodist".
|
# ? Oct 10, 2018 19:10 |
|
fam just gently caress me upcode:
|
# ? Oct 10, 2018 21:45 |
|
FISHMANPET posted:fam just gently caress me up
|
# ? Oct 10, 2018 21:50 |
|
FISHMANPET posted:fam just gently caress me up This is how I felt the first time I tried to do a for loop in Python.
|
# ? Oct 10, 2018 23:12 |
|
See I have a CS degree so I've done tons of programming in languages (C, C++, Python) with that for loop formulation, so the first few times I wrote one in Powershell I really had to scratch my head to wrap it around it.
|
# ? Oct 10, 2018 23:19 |
|
I've always done loops in C/C++/C# ascode:
code:
|
# ? Oct 10, 2018 23:29 |
|
FISHMANPET posted:fam just gently caress me up Post/Avatar combo on point
|
# ? Oct 11, 2018 00:41 |
|
The Fool posted:
|
# ? Oct 11, 2018 03:14 |
|
Oh, we're talking about silly code? https://twitter.com/flibitijibibo/status/1037011978600898560
|
# ? Oct 11, 2018 13:12 |
|
Collateral Damage posted:Oh, we're talking about silly code? I'm really proud of myself for learning enough powershell to understand why this is funny.
|
# ? Oct 11, 2018 14:35 |
|
I raise you https://github.com/auchenberg/volkswagen I loving lost it at INCEPTION_MODE https://github.com/auchenberg/volkswagen/commit/ae5d3b6b825bbf4e83b968d0b8835746ffc0a465 Methanar fucked around with this message at 23:37 on Oct 11, 2018 |
# ? Oct 11, 2018 23:35 |
|
Today I used PowerShell to split up a giant CSV and apparently just using the > redirector generates UTF-16-encoded files, and they ended up ginormous
anthonypants fucked around with this message at 00:15 on Oct 12, 2018 |
# ? Oct 12, 2018 00:12 |
|
Apparently you can muck about with the local shell variables prior to redirecting to change the encoding format. Personally if you need to be certain I like the specificity of Out-File -Encoding $Format.
|
# ? Oct 12, 2018 00:59 |
|
PierreTheMime posted:Apparently you can muck about with the local shell variables prior to redirecting to change the encoding format. Personally if you need to be certain I like the specificity of Out-File -Encoding $Format.
|
# ? Oct 12, 2018 01:07 |
|
anthonypants posted:Yeah, I decided I'd write up a script to do it for people who aren't me, and decided that would be a good method. Easier than figuring out how to use StreamWriter or whatever, anyway. Streams are actually pretty simple to work with and a lot faster. I posted about a similar topic a few pages back if you want an example I can provide one. I suppose it depends what “giant” means in your post, the ones I was working with were 20-40GB so the performance difference was significant.
|
# ? Oct 12, 2018 01:17 |
|
PierreTheMime posted:Streams are actually pretty simple to work with and a lot faster. I posted about a similar topic a few pages back if you want an example I can provide one. I suppose it depends what “giant” means in your post, the ones I was working with were 20-40GB so the performance difference was significant. Anyway, code:
anthonypants fucked around with this message at 01:42 on Oct 12, 2018 |
# ? Oct 12, 2018 01:36 |
|
|
# ? May 15, 2024 03:26 |
|
Can somebody here shed some light on the proper way to do this? I have a collection of custom objects that have different properties. I'm using a single loop to say if target matches object.propertyA, but if propertyA doesn't exist, check if target matches object.propertyB. To accomplish this I'm doing a try / catch, but since I expect the error a lot, catch returns $null. $collection = @[{name = A, a = a},{name = B, b = b}] Foreach ($thing in $collection) { Try{ If ($thing.a -match 'a'){return $true} } Catch {$null} Try { If ($thing.b -match 'b'){return $true} } Catch {$null} } For B, I expect the first if statement to throw an error complaining that property B.a doesn't exist. I want this error to be silent and for the script to move on. I'm guessing I shouldn't be doing a try catch here but can't come up with the right answer to use instead. Suggestions?
|
# ? Oct 12, 2018 01:38 |