|
while(1) {gc -Wait "\\path\to\update.status" | Select-String "succeeded" | % {break}} I'll show myself out.
|
# ? Sep 23, 2017 08:29 |
|
|
# ? Jun 13, 2024 05:26 |
|
The Fool posted:((get-content "\\path\to\update.status") -eq "succeeded") That's locked into an assumption of success. It should be checking for 'succeeded' or 'failed' at a minimum.
|
# ? Sep 23, 2017 21:52 |
|
PowerShell Unplugged with Jeffrey Snover and Don Jones https://www.youtube.com/watch?v=D15vh-ryJGk This is a fun video. The Fool fucked around with this message at 20:11 on Sep 29, 2017 |
# ? Sep 29, 2017 20:02 |
|
Anyone done XML validation against a schema in PowerShell? It looks somewhat straightforward using the .NET classes but but if anyone has a working sample that would be great!
|
# ? Sep 30, 2017 06:47 |
|
What's the best Powershell or even Azure JSON Template Github? Aside from the official Microsoft ones which aren't bad but don't have specific use cases.
|
# ? Oct 1, 2017 05:13 |
|
NYC PowerShell Meetup tonight. Serverless PowerShell using Azure functions, pretty cool stuff.
|
# ? Oct 9, 2017 20:28 |
|
Briantist posted:NYC PowerShell Meetup tonight. Serverless PowerShell using Azure functions, pretty cool stuff. Mostly off topic but I was in NYC for a holiday last week and I walked past this very building! I remember the Chevy's sign
|
# ? Oct 9, 2017 20:32 |
|
Briantist posted:NYC PowerShell Meetup tonight. Serverless PowerShell using Azure functions, pretty cool stuff. I am not in NY, otherwise I'd consider going. I'm working on a project where one of the components is some logic done in Powershell, hosted as an Azure function, to manipulate a Sharepoint List via CSOM. It was really fun putting that together.
|
# ? Oct 9, 2017 20:51 |
|
Anyone going to the Powershell thing in Phoenix on the 14th?
|
# ? Oct 9, 2017 21:43 |
|
Is the -online option for Get-Help taking everyone else to a 404 page? edit: Seems it's not everything. Get-Command takes me here which works: https://docs.microsoft.com/en-us/powershell/module/Microsoft.PowerShell.Core/Get-Command?view=powershell-4.0 Get-Childitem takes me here which 404s https://docs.microsoft.com/en-us/powershell/module/4.0/microsoft.powershell.core/providers/FileSystem-Provider/Get-ChildItem-for-Filesystem
|
# ? Oct 16, 2017 23:25 |
|
thebigcow posted:Is the -online option for Get-Help taking everyone else to a 404 page? https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/providers/filesystem-provider/get-childitem-for-filesystem anthonypants fucked around with this message at 23:50 on Oct 16, 2017 |
# ? Oct 16, 2017 23:47 |
|
Neato. I don't know where to file a bug for this.
|
# ? Oct 17, 2017 17:37 |
|
https://github.com/powershell edit: lol, anthonypants already submitted it: https://github.com/PowerShell/PowerShell/issues/5136 edit2: because I'm bored code:
The Fool fucked around with this message at 17:48 on Oct 17, 2017 |
# ? Oct 17, 2017 17:40 |
|
The Fool posted:https://github.com/powershell I guess I've got to learn this stupid new git thing that all the cool kids are talking about.
|
# ? Oct 17, 2017 17:45 |
|
The Fool posted:https://github.com/powershell
|
# ? Oct 17, 2017 18:19 |
|
Thank you!
|
# ? Oct 18, 2017 17:16 |
|
Irritated Goat posted:Ok. Help me believe I'm not insane. I ran into issues with ACL permission scripts because they were also trying to set the file owner, which was throwing access denied. Been a year or so since I've used it but I'm pretty sure this worked for NTFS perms: code:
|
# ? Nov 9, 2017 07:39 |
I'm wondering if there are some idioms or syntaxes I'm missing, working with the regular MS ActiveDirectory module. Say I have a list of user names, and a list of group names. I want to know what users are not in each group, and I want to simply add the missing users. Using Add-ADGroupMember with -Members @("user1", "user2") fails if even a single of the users is already member of the group, and making a loop (ForEach-Object) over the users is awkward and seems backward. Is there a better way? Is there a good way to present a table (matrix) of AD user objects (with MemberOf property fetched) with some select groups as columns, containing member true/false flags? One that doesn't involve a loop and Add-Member (or creating PSCustomObjects).
|
|
# ? Nov 14, 2017 12:54 |
|
nielsm posted:I'm wondering if there are some idioms or syntaxes I'm missing, working with the regular MS ActiveDirectory module. I'm phone posting, so I can't check this, but you could probably use Compare-Object cmdlet on outputs of Get-ADUser and Get-ADGroupMember, which should return you a list of users that are not in a specified group. Something like: code:
The Claptain fucked around with this message at 13:21 on Nov 14, 2017 |
# ? Nov 14, 2017 13:17 |
|
nielsm posted:I'm wondering if there are some idioms or syntaxes I'm missing, working with the regular MS ActiveDirectory module. I find it's easiest to compare arrays of common attribute value types with the -in / -notin comparison operators. Assuming you have two text-files with lists of users and groups something like this should work (The member AD attribute contains an array of all group members referenced by their distinguished name): code:
The Claptain posted:I'm phone posting, so I can't check this, but you could probably use Compare-Object cmdlet on outputs of Get-ADUser and Get-ADGroupMember, which should return you a list of users that are not in a specified group. I've found that using Compare-Object can be difficult as differences in object member sets can throw it off. It's usually easier to just compare arrays of strings.
|
# ? Nov 15, 2017 03:24 |
|
I need some help with getting powershell to display glyphs correctly. I'll preface this by saying I don't have a great grasp on fonts/glyphs/unicode. I'm using powershell to execute some Perl 6 code. It is not properly displaying glyphs that are in the output. After some googling, I've installed Unifont and am using the Powershell ISE but it still fails to display properly. Here is what the output looks like: Any ideas?
|
# ? Nov 26, 2017 18:53 |
|
Try ConEmu
|
# ? Nov 26, 2017 20:48 |
|
I'll give that a look. Thanks!
|
# ? Nov 26, 2017 21:33 |
|
PowerShell doesn't have problems parsing unicode, it looks like that's a problem with perl.
|
# ? Nov 26, 2017 22:41 |
|
Is there a way to break up a single line powershell command across multiple lines, allowing for easier readability, but still being able to copy/paste it directly into a Powershell prompt? I've got something like code:
|
# ? Dec 29, 2017 22:15 |
|
Use backtick ` not caret ^
|
# ? Dec 29, 2017 22:23 |
Or splat it:code:
|
|
# ? Dec 29, 2017 23:36 |
|
nielsm posted:Or splat it: Do this, it's the preferred method to ` from everything I found.
|
# ? Dec 29, 2017 23:39 |
|
Inspector_666 posted:Do this, it's the preferred method to ` from everything I found. As long as you do it with hash tables and not arrays. IMO you should always be using named parameters for cmdlets. It's far less ambiguous and less likely to break compared to using positional parameters.
|
# ? Dec 30, 2017 07:27 |
|
Seconding splatting - it makes poo poo so much easier to read.
|
# ? Jan 3, 2018 22:39 |
|
Question guys, that's hopefully basic. I have a script that grabs a CSV of all detected AV threats from the web, saves it to $output, sorts it, selects certain columns, than bundles those off into HTML and emails it. There's a certain column in the CSV, which is called "Last Found." In that column, it simply lists the date that the threat was last found, in the following format: MM/DD/YYYY HH/MM. An example would be "1/12/2018 19:16" What I want to do is compare that against the current date, and remove all rows where "Last Found" is over a week from the current date. I think the way I want to do this is something like what I have below: code:
Once that's done, I just call the rest of my script like normal. Relevant bits below: The relevant command: code:
|
# ? Jan 15, 2018 17:48 |
|
I'm leaving the office now, But I just wanna say. You should give the book "Powershell in a month of lunches" a read. It's a great book. Edit: Really quickly at the top of my head. Would something like (Get-Date).AddDays(-7) work? Sefal fucked around with this message at 18:02 on Jan 15, 2018 |
# ? Jan 15, 2018 17:58 |
|
The Iron Rose posted:in the following format: MM/DD/YYYY HH/MM. An example would be "1/12/2018 19:16" Just to be clear, which format is it, because the format you posted and the date you posted, are not the same in several ways.
|
# ? Jan 15, 2018 17:59 |
|
Sefal posted:I'm leaving the office now, But I just wanna say. You should give the book "Powershell in a month of lunches" a read. I’m phone posting so it’s not easy to post some sample code, but this is the right direction. You need to convert your date strings into date-time objects, subtract 7 days from the current date, then you can do direct comparisons and filter using where-object. https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/get-date The Iron Rose posted:One other thing to note - I don't know poo poo about powershell and I'm mostly just learning by doing, well, things like this at work. Any pointers would be greatly appreciated. One liners are only good for e-penis competitions and copy-pasting. If you are writing scripts to be saved and reused, be as verbose as is practical so that it is easier to go back and maintain your poo poo afterwards. The Fool fucked around with this message at 18:18 on Jan 15, 2018 |
# ? Jan 15, 2018 18:13 |
|
The Iron Rose posted:Question guys, that's hopefully basic. Assuming the date in the "Last Found" column is well-formed you can use a filter like this: code:
|
# ? Jan 15, 2018 18:19 |
|
code:
|
# ? Jan 15, 2018 18:35 |
|
The Fool posted:
Jeez you've gone a bit overboard with the brackets there mate. Also script blocks should be contained in curly brackets: code:
|
# ? Jan 15, 2018 18:43 |
|
Yeah, I mess up the curly braces all the loving time and did nothing to valid the snippet I posted.
|
# ? Jan 15, 2018 18:48 |
|
The Fool posted:I’m phone posting so it’s not easy to post some sample code, but this is the right direction. Yep, this is the direction I'm heading in. Forgetting about the rest of what I need my script to do, right now I'm just trying to get the compare working. So I wrote this up for testing. code:
E: Wow I need to refresh before posting more, thank you all so much! cheese-cube posted:Jeez you've gone a bit overboard with the brackets there mate. Also script blocks should be contained in curly brackets: This one looks real neat, and I think the -gt flag is what I want to use in this case! That's way easier than doing individual variables for every single day I want to go back a la the snippet I posted above. I think I need to understand what it's doing exactly before trying to integrate it into the rest. It looks like it's taking $output (which is the ThreatsDataReport.csv), piping it to Where-Object, where it looks like it's trying to get the date from "Last Found". Subsequently, the -gt flag is meant to ensure that the rows are greater than the current date minus 7 days are passed back to $output. I think I have that correct at any rate! The problem here is that a) I'm not sure that it's matching correctly thanks to the drat time appended to the date in the .CSV, and b) this is just storing the rows to $output, right? Not an actual .csv I can then call with import-csv (which is what I use to sort, select certain columns, and convert to HTML. Actually hell with it, I'll just post the rest of the script. code:
If I do something like: code:
E: gonna take a breather for now, do some more research, and come back with some better questions. Thanks for all y'all's help so far, it's very appreciated. The Iron Rose fucked around with this message at 19:15 on Jan 15, 2018 |
# ? Jan 15, 2018 18:55 |
|
|
# ? Jun 13, 2024 05:26 |
|
As others have mentioned the main difficulty you might have is casting that "Last Found" value as a DateTime object. That depends entirely on whether or not it's well formed which will become apparent as soon as you run the script (I'm pretty sure Get-Date calls the Parse() method of System.DateTime if you pass it a string which will throw an exception if it can't parse it). Of course if it does parse as a DateTime object then you can go hog-wild with comparing it to other DateTime objects, amongst other things.
|
# ? Jan 15, 2018 19:08 |