purge the klist and see if there are any other creds stored.
Submarine Sandpaper fucked around with this message at 18:18 on Dec 22, 2020 |
|
# ? Dec 22, 2020 18:11 |
|
|
# ? Jun 3, 2024 22:57 |
|
How is the WinRM trusted hosts list distributed? Can you verify that they're the same on all servers?
|
# ? Dec 22, 2020 18:24 |
|
Submarine Sandpaper posted:purge the klist and see if there are any other creds stored. Server has been rebooted twice since I initially posted this, so that would've cleared this. I haven't set up a WinRM trusted hosts list that I know of. For all the other cross-domain servers it's just worked (before the domain trust was set up we were using CredSSP, and that still works)
|
# ? Dec 22, 2020 18:29 |
Lum posted:Both servers are in the same subnet with the same firewall rules, and I can RDP to both of them using my DomainA\Admin account. Neither of them have domainA.local in their DNS search suffixes. Both of them are able to contact the DomainA DCs on the same port numbers (445 etc.) The thing to me here is that you're getting told wrong username/password and not some other error message, which in a domain trust (to me) says something isn't reaching the other side of the trust properly. So on one of these without the explicit switch it's trying [username]@domainb.com instead of [username]@domaina.com. Or it's sending the right request to the wrong server. Something like that. You should actually be able to see that in the security logs afaik if it's either a username problem or a getting sent to the wrong domain problem. I'd bet cash money the credential switch will force it to use the correct domain which is why PS can sidestep the issue that way. RDP requires it anyways. Are you totally, 100% sure DNS is the same on both of these server? No host file weirdness inserted for a poo poo Domain Trust deployment? edit: There's always the possibility it's some weird PS bug, are the versions of PS the same on both of the servers? I kinda didn't think about that and have been assuming working server 1 and busted server 2 are identical in that regard. i am a moron fucked around with this message at 18:44 on Dec 22, 2020 |
|
# ? Dec 22, 2020 18:37 |
|
i am a moron posted:The thing to me here is that you're getting told wrong username/password and not some other error message, which in a domain trust (to me) says something isn't reaching the other side of the trust properly. So on one of these without the explicit switch it's trying [username]@domainb.com instead of [username]@domaina.com. Or it's sending the right request to the wrong server. Something like that. You should actually be able to see that in the security logs afaik if it's either a username problem or a getting sent to the wrong domain problem. I'd bet cash money the credential switch will force it to use the correct domain which is why PS can sidestep the issue that way. RDP requires it anyways. PS version is 5.1.14009.1018 on both servers and the rest of $PSVersionTable is identical too. Hosts files are identical The domain trust deployment was recent and was done by the guy above me, who seems to know his poo poo. As far as I'm aware it was pretty straightforward. Security logs don't show any login failures, but that might be just because that's turned off, or I'm looking at the wrong one (looking in the event log) Edit: So I turned on the failure audit policies for account login events, directory service access, logon events and privilege use and my attempts to log in still don't show in that log (though I can see unrelated failures) Lum fucked around with this message at 11:35 on Dec 23, 2020 |
# ? Dec 23, 2020 11:25 |
|
I had to add some fields to the end of a section inside an old-school .INI file today and I wrote this code with equal parts shame and pride:code:
|
# ? Dec 30, 2020 16:46 |
|
Man, you are getting the content of that file way too many times.
|
# ? Dec 30, 2020 17:07 |
|
FISHMANPET posted:Man, you are getting the content of that file way too many times. Definitely, yeah. But it's inconsequential, so I didn't worry about it.
|
# ? Dec 30, 2020 17:10 |
|
Wizard of the Deep posted:How is the WinRM trusted hosts list distributed? Can you verify that they're the same on all servers? I lean on dsc with [insert any popular config/security management solution here]
|
# ? Dec 30, 2020 23:06 |
|
Does anyone have a decent ps script for deploying a simple site to IIS? google had some mixed results dont need anything really fancy.
|
# ? Jan 8, 2021 17:42 |
|
What the hell am I missing here? Is this some bizarre PowerShell Syntax thing I'm not understanding? I just want to write a small script that takes a large array and splits into smaller individual arrays.code:
|
# ? Feb 18, 2021 04:09 |
|
Crosby B. Alfred posted:What the hell am I missing here? Is this some bizarre PowerShell Syntax thing I'm not understanding? I just want to write a small script that takes a large array and splits into smaller individual arrays. The whole "dynamically creating new sequentially numbered variables" thing is a huge code smell. What are you actually trying to do here? The typical approach for this is to put them into a hash table (@{}) or into an array that you can iterate over. It looks to me like you want an array of arrays.
|
# ? Feb 18, 2021 04:49 |
|
Crosby B. Alfred posted:What the hell am I missing here? Is this some bizarre PowerShell Syntax thing I'm not understanding? I just want to write a small script that takes a large array and splits into smaller individual arrays. If I'm reading this right, it seems like an issue with your OutputArray variable. Am I right in thinking that that New-Variable line is intended to index into a variable called OutputArray? That's not what it's doing; on the first iteration of that loop, for instance, it's creating a variable called OutputArray[1]; the [1] is part of the variable name you're creating with that command, not an index operator. Later on, you've got ('$outputArray'+$count) += ,@($InputArray[$start..$end]), which has a few problems as well. You've got $outputArray in single quotes, so the string is literally $outputArray, not the value of the variable named outputArray. Swapping in double quotes wouldn't fix the bigger problem with that line, though: you're trying to assign a value to a string—not a variable of type string, but a string itself. I hope this hasn't come off as overly harsh. I think there's probably a simpler way to do this, and I'll see what I can put together. To make sure I'm headed in the right direction, what are you trying to do with the smaller arrays that isn't working with the large one?
|
# ? Feb 18, 2021 05:09 |
|
Toast Museum posted:If I'm reading this right, it seems like an issue with your OutputArray variable. Am I right in thinking that that New-Variable line is intended to index into a variable called OutputArray? That's not what it's doing; on the first iteration of that loop, for instance, it's creating a variable called OutputArray[1]; the [1] is part of the variable name you're creating with that command, not an index operator. I know doing something wrong with line 14 but I'm not sure how to fix it? On line 10 I'm trying to create arrays determined by the $ChunkSize. For example, if I have a large array of 10,000+ objects, $ChunkSize is set to 10, this would create 10 arrays and they'd have a size of 1,000 each. I guess what I am missing is how do I assign or modify my dynamic variables per line 14? I saw some earlier examples online that used the Set-Variable cmdlet but this still resulted in the same error and just left that section commented out.
|
# ? Feb 18, 2021 20:26 |
|
I'm still trying to figure out what your intent is with this.
|
# ? Feb 18, 2021 21:26 |
|
Dirt Road Junglist posted:I'm still trying to figure out what your intent is with this. The dataset I'm working with is enormous but if I split it into smaller arrays to work with them in memory that'll work.
|
# ? Feb 18, 2021 22:11 |
Can you do what you want to do with the data using a -parallel switch anywhere without jumping through these hoops? I see what you want to do and there's just gotta be a better way.
|
|
# ? Feb 18, 2021 22:20 |
|
There's probably a better way but I'm still absolutely perplexed why I can't get 14 to function correctly.
|
# ? Feb 18, 2021 22:30 |
|
Crosby B. Alfred posted:The dataset I'm working with is enormous but if I split it into smaller arrays to work with them in memory that'll work. Not sure this will buy you the performance you're looking for but here's what I've got. It seems to work but YMMV and so forth. I did use the PS7 ternary operator so you may have to tweak that if you're not using 7. code:
|
# ? Feb 18, 2021 23:54 |
|
Crosby B. Alfred posted:The dataset I'm working with is enormous but if I split it into smaller arrays to work with them in memory that'll work. Serialize your data and write it to a file and then only process what you can handle at a time. Or just use a bigger machine.
|
# ? Feb 19, 2021 00:02 |
|
Zaepho posted:Not sure this will buy you the performance you're looking for but here's what I've got. It seems to work but YMMV and so forth. I did use the PS7 ternary operator so you may have to tweak that if you're not using 7. I'm stuck with line 9... Trying to fix it myself, but how is this : operator supposed to function?
|
# ? Feb 19, 2021 00:14 |
|
Crosby B. Alfred posted:I'm stuck with line 9... Trying to fix it myself, but how is this : operator supposed to function? code:
|
# ? Feb 19, 2021 00:21 |
|
Crosby B. Alfred posted:There's probably a better way but I'm still absolutely perplexed why I can't get 14 to function correctly. As written, code:
code:
code:
Changing the single quotes to double quotes won't fix that line, though. The next hurdle is that the variable you're calling, $outputArray, hasn't been declared. On line 10, code:
From a performance standpoint, I'm not sure whether creating a bunch of variables to contain subsets of a large collection provides any benefit over just using the indexer on the big collection to call ranges of indices. It really does seem like there's got to be a better way to handle this than generating a bunch of new variables, but I know that "how do I do thing"/"you shouldn't do thing" is an frustrating conversation, so here's a lightly-tested function for splitting up a collection and assigning each subset to a variable: code:
|
# ? Feb 19, 2021 00:43 |
|
Zaepho posted:
I'm still getting weird errors with this but the next script functions as expected or there's something up with my workstation. New-Variable : Cannot create variable OutputArray4172 because variable capacity 4096 is exceeded for this scope. Toast Museum posted:As written, I'm referencing a freaking string named $outputarray7 Is it not possible to reference dynamic variables in PowerShell in way I'm attempting to do here? I was under the impression that it possible to merely return something like $OutputArray1, $OutputArray2, $OutputArray3, etc. Toast Museum posted:Changing the single quotes to double quotes won't fix that line, though. The next hurdle is that the variable you're calling, $outputArray, hasn't been declared. On line 10, My intent here was to reference one of my earlier dynamically created variables and populate it with the contents of $InputArray. This answers my earlier question, I could just use the ugly syntax of${OutputArray[$count]} on line 14 but what's weird is that I'm getting the same error messages as Zaepho's script but the one you created runs flawlessly. Performance or best practice standards aside, this should still work... right? code:
code:
Edit - I had the wrong variable name earlier, I'm no longer getting the variable capacity error but none of my dynamic variables are being populated. Gucci Loafers fucked around with this message at 15:43 on Feb 23, 2021 |
# ? Feb 22, 2021 23:04 |
|
Crosby B. Alfred posted:I'm still getting weird errors with this but the next script functions as expected or there's something up with my workstation. It's news to me, but apparently a given scope (or at least the global scope) can only handle 4096 declared variables at a time in Windows PowerShell. I need to stare at the script that's throwing the error a bit more to see exactly where the problem is, but I suspect that $ChunkSize is involved. Your script uses that variable to define how many chunks there are, rather than how big each chunk is, which is kinda misleading, and I have a feeling there's a mix-up over that detail at some point. quote:I'm referencing a freaking string named $outputarray7 You can do that, and I think you're just a little hung up on the syntax on variables and index operators. I hope this clears it up some: code:
Toast Museum fucked around with this message at 07:06 on Feb 23, 2021 |
# ? Feb 23, 2021 06:57 |
|
Crosby B. Alfred posted:I'm still getting weird errors with this but the next script functions as expected or there's something up with my workstation. I've never seen that error before and did not know that there was a per-scope variable limit. IMO this is a very clear sign that you're not approaching things in maybe the worst way possible. Edit: if you want to just get chunks of an array you can use Select-Object with the First and Skip parameters. For example: code:
Pile Of Garbage fucked around with this message at 10:42 on Feb 23, 2021 |
# ? Feb 23, 2021 10:35 |
|
Why would someone do this?code:
|
# ? Feb 23, 2021 20:15 |
|
Toshimo posted:Why would someone do this? Edit: Or if you mean "why would someone write code like this" rather than "what does it do" then I guess the answer is "lol powershell" ? mystes fucked around with this message at 20:28 on Feb 23, 2021 |
# ? Feb 23, 2021 20:22 |
|
mystes posted:The last part will remove empty strings. You're splitting each input string on "," flattening the output, and then removing empty strings. Yeah, I mean they literally did that on a line to feed it into a foreach loop instead of: $somelist = ("foo","bar","baz")
|
# ? Feb 23, 2021 20:33 |
|
Toshimo posted:Why would someone do this? Copy Pasta. Probably got some examples from different places to do what they thought they needed to do and just altered it to fit rather than understanding the right way to do it.
|
# ? Feb 23, 2021 20:53 |
|
Zaepho posted:Copy Pasta. Probably got some examples from different places to do what they thought they needed to do and just altered it to fit rather than understanding the right way to do it. Yeah, their entire script is full of choice tidbits like this, which is why someone brought it to me to decipher. It'll probably get rubber stamped to go to prod anyway, but at least someone is asking questions.
|
# ? Feb 23, 2021 21:01 |
|
Crosby B. Alfred posted:I'm still getting weird errors with this but the next script functions as expected or there's something up with my workstation. OK, I think there's some things you're missing about variables. One thing you may have figured out now but to be clear, in PowerShell, something like $variable indicates you're referencing a variable with the name variable. The $ isn't part of the variable name, it just indicates to the interpreter that you're referencing a variable. Also, something to know about variables in strings. When you put a string in single quotes ('my great variable $var') Powershell does no interpolation, the value will literally be 'my great variable $var. If you put the same string in double quotes, it will interpolate the variable, so if $var has a value of foo then "my great variable $var" will be my great variable foo So others have mentioned but in your latest example let's look at this line: code:
Because of the your code is written, it runs, but it just keeps stuffing all the values into OutputArray[$count] rather than OutputArray[1], OutputArray[2], etc I felt generous, and also to actually understand what you were trying to do, I rewrote this in a couple ways. First, actually creating an array of arrays. No need mess around with dynamically defining variable names, though you're treating the array in a very non-powershell way so this is kind of weird, having to pre-initialize the output array so that you can actually insert into it. code:
If you're truly interested in Dynamic variables, well here you go. This is very messed up because what you're trying to do is again... very messed up code:
|
# ? Feb 24, 2021 20:36 |
|
FISHMANPET posted:Get-Variable Oh hey, thing I can use in my lunch n' learn in a couple weeks. I'm doing an introductory thing, so I'll start with some simple console tricks and show off how it remembers your variables. Then some Active Directory stuff, ending up with adding a user to a group, then make it easier to type with variables, then the Get-Content/foreach() combo. After that, spend as much time as I've got to turn it into a real script with parameters and functions for logging, timestamps, and verifying that everything that was supposed to happen got done. Basically taking people from maybe knowing a few commands to being able to turn a one-liner into a resuable script.
|
# ? Feb 25, 2021 02:54 |
|
mllaneza posted:Oh hey, thing I can use in my lunch n' learn in a couple weeks. A good thing to add at the end might be a brief mention of how all objects are .NET classes and how to discover functionality using Get-Member, the GetType() method and Googling class names. Also make sure they know about the PowerShell "about" topics. They're core to defining how PowerShell behaves and yet a lot of people I meet who're just starting out have no idea that they exist.
|
# ? Feb 27, 2021 12:38 |
|
Pile Of Garbage posted:A good thing to add at the end might be a brief mention of how all objects are .NET classes and how to discover functionality using Get-Member, the GetType() method and Googling class names. Also make sure they know about the PowerShell "about" topics. They're core to defining how PowerShell behaves and yet a lot of people I meet who're just starting out have no idea that they exist. Some of that's getting saved for the "intermediate" session, but thanks !
|
# ? Feb 28, 2021 04:03 |
|
I need to determine which mailboxes (of disabled users) are forwarding to oldmanager, and then either turn off the forwarding or change it to newmanager - which one of those it will be is TBD. This is on-prem Exchange 2016, how do I begin?
|
# ? Mar 2, 2021 17:29 |
|
TITTIEKISSER69 posted:I need to determine which mailboxes (of disabled users) are forwarding to oldmanager, and then either turn off the forwarding or change it to newmanager - which one of those it will be is TBD. This is on-prem Exchange 2016, how do I begin? Google and the documentation are usually good starting points. Have you tried anything or done any research on your own about how to accomplish your goal?
|
# ? Mar 2, 2021 22:54 |
|
It should also be pretty straightforward, use Get-ADUser with whatever filter you need to grab your disabled users to generate the list of mailboxes to check, then use Get-Mailbox to find which ones are forwarding to the oldmanager. I'd probably put that output into a CSV to easily see what you're working with and then you can run the final script against it, which should just be a Set-Mailbox command.
|
# ? Mar 2, 2021 23:14 |
|
I have a stupid problem: I have two json documents from different sources, and I want to dump both of them into a text file. That part is easy enough. The hard (?) and stupid part is that the end result should be two .json files that can be textually diffed against each other, to see if the two sources of truth disagree. This means that I need the output normalized, e.g. by writing the keys in a lexicographical order... Is there a simple way to do that?
|
# ? Mar 5, 2021 15:57 |
|
|
# ? Jun 3, 2024 22:57 |
|
Xarn posted:I have a stupid problem: I have two json documents from different sources, and I want to dump both of them into a text file. That part is easy enough. Can't you just sort the two files regardless of syntactic correctness and then compare line by line? Something like this: code:
New Yorp New Yorp fucked around with this message at 16:38 on Mar 5, 2021 |
# ? Mar 5, 2021 16:18 |