|
One of the steps in our server build guide is to enable auditing for the C:\ drive. I'd like to script this out but I can't for the life of me find any relevant resources. Oh and while I'm asking, when doing this manually we tend to see a lot of access denied errors on subfulders, anyone know what that's about?quote:h) Enable Auditing for System Drive
|
# ? Jan 14, 2014 16:53 |
|
|
# ? May 9, 2024 22:07 |
|
http://blogs.technet.com/b/bulentoz...ll-scripti.aspx
|
# ? Jan 15, 2014 06:16 |
|
thank you thank you thank you. I modified it to suit my needs... here's what I came up with to make it match the above screenshot in case anyone else sees this. code:
|
# ? Jan 15, 2014 18:25 |
|
When you use invoke-command to drop a script block on a remote Hyper-V server with credential variables. Does PS leave anything on the remote computer by way of a temp file, memory blocks, etc or does it clean up after itself as it finishes up the command? Scenario: We're using invoke-command to automate deployment of servers that need specific credentials for setup, we send over the script, do all the goodies, and it ends. Nothing should be left behind from that script hopefully.
|
# ? Jan 16, 2014 14:57 |
|
I'm not having any luck googling this, does anyone know how to use a substring in a get-adcomputer filter? So, for example, let's say a naming convention is STATECITY00006, and I want all of the computers in Utah, I would assume the command would becode:
code:
|
# ? Feb 7, 2014 15:54 |
|
So they aliased wget in powershell 3. Any idea why it is horribly slow compared to any other http download client? Sub 100mb speeds on a gigabit network with nothing happening slow FWIW.
|
# ? Feb 7, 2014 16:22 |
|
AreWeDrunkYet posted:I'm not having any luck googling this, does anyone know how to use a substring in a get-adcomputer filter? So, for example, let's say a naming convention is STATECITY00006, and I want all of the computers in Utah, I would assume the command would be code:
|
# ? Feb 7, 2014 21:20 |
|
Jethro posted:
Unfortunately, it has to be in the exact position I am looking for it (and not always at the beginning or end of the string). So, to run with the existing example, XXUTAHXXXX would be a match but I would not want to return XXXUTAHXXX. It appears the only wildcard -like accepts is *, and code:
I was able to work around it, but my solution is pretty inefficient. A solution that would let me use the filter in get-adcomputer would probably run much faster. code:
|
# ? Feb 7, 2014 21:50 |
|
I don't know if this has better performance, but you can pipe to a filter:code:
|
# ? Feb 8, 2014 13:38 |
|
You can also just use regular expressions.
|
# ? Feb 8, 2014 14:48 |
|
It'd be nice if -filter on most of the AD cmdlets was better, I think it's just a basic wrapper for LDAP query stuff so it's fairly limited.
|
# ? Feb 8, 2014 15:08 |
|
AreWeDrunkYet posted:Unfortunately, it has to be in the exact position I am looking for it (and not always at the beginning or end of the string). If you don't want to bother with regex (you probably should, though), I would suggest that you should use the filter on Get-ADComputer to get a broad list of stuff that probably contains what you want, instead of using * to get absolutely everything. Then your foreach loop will (probably) run a lot faster, because it'll only be parsing through anything that contains utah instead of everything else, too. Something I found out recently too was that if (like me) your company's AD is poo poo and full of stuff that doesn't even exist anymore, you can pipe Get-ADComputer into Test-Connection -quiet -count 1 to get only computers that you can actually ping (which it will try once instead of the default four times). And a quick question I have: I'm doing the powershell software inventory thing myself as busy work. My script works, and it returns things that I personally can count and say "We have X installations of Product", but it returns poo poo like "Adobe Soundbooth" "Adobe Soundbooth Codecs" "Adobe Soundbooth Scores" "Adobe Soundbooth other bullshit". Is there any easy way that I just can't think of to only grab the installation for a real product, instead of all the dumb poo poo that comes with it? This is particularly frustrating for things like Microsoft SQL Server which, by itself, returns about 180 different versions of different plugins/tools/etc for Microsoft SQL Server. e: The only thing I've come up with so far is "use the one with the biggest count and, given a tie, the one with the shortest name", but even that isn't particularly graceful. 12 rats tied together fucked around with this message at 22:06 on Mar 1, 2014 |
# ? Mar 1, 2014 22:04 |
|
I have used powershell before for simple scripts and have a decent grasps of the concepts but what I thought would be a relatively easy script is turning into a real pain. What I'm trying to do: Create a script that moves files that have been modified in a date range to a new location. Some of the folders in the main folder have many levels of nested subfolders beneath it. Preferably it would keep the same folder structure but this is not required. The files total up to a couple TB so it has to be a move, copying will take hours to process. Here is what I currently have: code:
I tried running "robocopy $source $dest /e /xf *.*" beforehand to recreate the folder structure but then the move-item errors because the folders already exist. Is there a way to accomplish this?
|
# ? Mar 12, 2014 22:01 |
|
Deranged Milkman posted:I have used powershell before for simple scripts and have a decent grasps of the concepts but what I thought would be a relatively easy script is turning into a real pain. I had a problem with this once on PS 2.0, Move-Item seems to not be able to overwrite existing folders. Instead, I did Copy-Item, then ran Remove-Item on the source once I copied. Same result, dumb workaround way of doing it because I did have that same behaviour. Haven't retried these methods on PS 3 or 4.
|
# ? Mar 12, 2014 22:13 |
|
Reiz posted:And a quick question I have: I'm doing the powershell software inventory thing myself as busy work. My script works, and it returns things that I personally can count and say "We have X installations of Product", but it returns poo poo like "Adobe Soundbooth" "Adobe Soundbooth Codecs" "Adobe Soundbooth Scores" "Adobe Soundbooth other bullshit". Is there any easy way that I just can't think of to only grab the installation for a real product, instead of all the dumb poo poo that comes with it? This is particularly frustrating for things like Microsoft SQL Server which, by itself, returns about 180 different versions of different plugins/tools/etc for Microsoft SQL Server. The only reliable workaround I've found is maintaining a master list of software we might be looking for, and matching those strings against the report from what's installed on the workstation. Even filtering out everything that's an update or a duplicate will leave you with a very bloated list.
|
# ? Mar 12, 2014 22:27 |
|
CLAM DOWN posted:I had a problem with this once on PS 2.0, Move-Item seems to not be able to overwrite existing folders. Instead, I did Copy-Item, then ran Remove-Item on the source once I copied. Same result, dumb workaround way of doing it because I did have that same behaviour. Haven't retried these methods on PS 3 or 4. This would take a few hours to process due to the files size but if I can't find anything else that might be an option. My other problem is it checking the modify date on the folders and not the files within it. Is there a way to have it look at the contents and not the modify date on the folder?
|
# ? Mar 13, 2014 01:51 |
|
Reiz posted:Yeah you can probably do this with a regex. \w\wUTAH would (probably) match a case for any two letters followed by UTAH. I've found this page pretty helpful in the past, and (depending on the pattern) it can be as specific as you want to be. I think \w{2} is a little clearer than \w\w although they're semantically equivalent. You can try regexpal.com for some help interactively composing regexes, by the way.
|
# ? Mar 13, 2014 03:35 |
|
Deranged Milkman posted:This would take a few hours to process due to the files size but if I can't find anything else that might be an option. My other problem is it checking the modify date on the folders and not the files within it. Is there a way to have it look at the contents and not the modify date on the folder? Yeah I get that it would take a while, but I think it's a lovely limitation of move-item and you might not have a choice. As for your other thing, I honestly would just use robocopy at this point.
|
# ? Mar 13, 2014 17:44 |
Hey, so I'm not sure if anything like this has been asked in the thread, but does anyone know how to interact with USB devices via powershell? I have a human interface device, and according to some basic googling, I was able to get a list of all the attached devices. I know what one I want to deal with, but I don't know how to do anything with it. Shouldn't I be able to query the device itself somehow? Get methods or something? The things I've been able to find are more along the lines of "List all the attached USB devices" or "Enable or Disable attached devices, just like Device Manager." I'd like to try and open the device and actually do stuff with it.
|
|
# ? Mar 31, 2014 19:19 |
|
One note on finding __UTAH____ -- you can pass a function to a filter -- see http://stackoverflow.com/questions/15536611/how-to-pass-custom-filter-function-to-where-object for an example. So you don't need a 2 stage filter. Personally I would skip the regex here but that is probably because I hate regexes.
|
# ? Apr 2, 2014 14:05 |
|
Is there anyway to send a foreach format-list to a csv with each property as a new column? For example, I want to run this: code:
pre:RunspaceId : [redacted] AutomateProcessing : AutoAccept AllowConflicts : False BookingWindowInDays : 180 MaximumDurationInMinutes : 43200 AllowRecurringMeetings : True EnforceSchedulingHorizon : True ScheduleOnlyDuringWorkHours : False ConflictPercentageAllowed : 0 MaximumConflictInstances : 0 ForwardRequestsToDelegates : True DeleteAttachments : True DeleteComments : False RemovePrivateProperty : True DeleteSubject : False AddOrganizerToSubject : True DeleteNonCalendarItems : True TentativePendingApproval : True EnableResponseDetails : True OrganizerInfo : True ResourceDelegates : {} RequestOutOfPolicy : {} AllRequestOutOfPolicy : False BookInPolicy : {} AllBookInPolicy : True RequestInPolicy : {} AllRequestInPolicy : False AddAdditionalResponse : False AdditionalResponse : RemoveOldMeetingMessages : True AddNewRequestsTentatively : True ProcessExternalMeetingMessages : False RemoveForwardedMeetingNotifications : False MailboxOwnerId : [redacted] Identity : [redacted] IsValid : True ObjectState : Changed edit: Never mind, I think I got it working with this: code:
code:
Figured it out: code:
kiwid fucked around with this message at 16:51 on Apr 4, 2014 |
# ? Apr 4, 2014 16:17 |
|
wwb posted:One note on finding __UTAH____ -- you can pass a function to a filter -- see http://stackoverflow.com/questions/15536611/how-to-pass-custom-filter-function-to-where-object for an example. So you don't need a 2 stage filter. Thanks, just ended up just dropping the filter and instead dealing with the strings once the list of computers was a PowerShell object. It takes a little while longer to run, but not unreasonably so considering I am trying identify a couple thousand objects from a list of 50k+.
|
# ? Apr 4, 2014 16:28 |
|
On my home PC (windows 8 pro), I've got a powershell script which runs every day and I need it to email me the results of the run. How can I accomplish this? I know that I can use the Send-MailMessage cmdlet to do the sending but I'm stumped as to what to use as the smtp server since I dont have one on my home network. Is there some way that I can use gmail's smtp servers to do this? Is there some other easy way? Thanks.
|
# ? Apr 13, 2014 01:16 |
|
Mr. Clark2 posted:On my home PC (windows 8 pro), I've got a powershell script which runs every day and I need it to email me the results of the run. How can I accomplish this? I know that I can use the Send-MailMessage cmdlet to do the sending but I'm stumped as to what to use as the smtp server since I dont have one on my home network. Is there some way that I can use gmail's smtp servers to do this? Is there some other easy way? Thanks. Seriously? http://lmgtfy.com/?q=gmail+smtp&l=1
|
# ? Apr 13, 2014 01:26 |
|
Thanks but I'm really asking more about how to pass along my gmail address/credentials to the send-mailmessage, I'm well aware of the actual smtp settings I did find this: http://www.powershellmagazine.com/2012/10/25/pstip-sending-emails-using-your-gmail-account/ but it still prompts the user to enter the password so wont work for what I'm trying to do.
|
# ? Apr 13, 2014 01:34 |
|
Mr. Clark2 posted:Thanks but I'm really asking more about how to pass along my gmail address/credentials to the send-mailmessage, I'm well aware of the actual smtp settings Did you try any of the solutions from this SO thread? Basically, use System.Net.Mail.SMTPClient instead.
|
# ? Apr 13, 2014 03:10 |
|
I have a quick question about Invoke-RestMethod. I tried to use this to post some multipart/formdata to my application in the following way: code:
Anyone know if i am doing something wrong? Curl works fine because it creates a valid request.
|
# ? Apr 13, 2014 09:32 |
|
Ithaqua posted:Did you try any of the solutions from this SO thread? Thanks, thats what I ended up doing.
|
# ? Apr 13, 2014 16:13 |
|
Mr Shiny Pants posted:I have a quick question about Invoke-RestMethod. I tried to use this to post some multipart/formdata to my application in the following way: To answer my own question. It seems that creating the form to post multipart data is left to the user. Creating form data is a PITA.
|
# ? Apr 14, 2014 05:38 |
|
So, we've recently changed our policy for our help desk to start filling in all the fields in an Active Directory user that we never really cared about before, such as organization information, addresses, phone numbers, etc. We've also moved to Office 365 which requires manually editing the proxyAddresses attribute for alias email addresses. They aren't very consistent with filling this information out and often forget to connect home drives and poo poo. I want to create a dummy proof PowerShell script that goes through the process of creating a new user but my experience with PowerShell is running one off commands. If you guys had to choose one book (maybe two), to learn PowerShell (especially syntax), what would it be?
|
# ? Apr 15, 2014 14:25 |
|
Is there a WMI equivalent to this code block:code:
|
# ? Apr 15, 2014 14:43 |
|
I've got this one-off powershell script that 1) changes the proxy settings, 2) downloads a file, and 3) puts the proxy settings back. Steps 1 and 2 go just fine, but step 3 never works. Powershell is not really my forte, so I'm probably doing something really dumb. code:
|
# ? Apr 15, 2014 15:33 |
|
And of course, soon after I post that, I realize that it's a scope issue. Problem solved.
|
# ? Apr 15, 2014 16:55 |
|
Virigoth posted:Is there a WMI equivalent to this code block: Just fooling around with this myself now, if you go: code:
You can see a property called "FullDNSRegistrationEnabled". If you set that to false, it should have the same effect as your above DNS cmdlets for v3+.
|
# ? Apr 15, 2014 17:16 |
|
I'm writing a pre-commit git hook in powershell that checks the syntax of Ruby files. The command I'd like to run is:code:
quote:The term 'C:\opscode\chef\embedded\bin\erb.bat -P -x -T '-' <file path> | C:\opscode\chef\embedded\bin\ruby.exe -c' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
|
# ? Apr 15, 2014 17:51 |
Try dropping the quotes, that way your variables will be the files you want instead of a string that happens to be the path to the file. (I think, dunno about the -P -x -T stuff) e: code:
SniperWoreConverse fucked around with this message at 19:06 on Apr 15, 2014 |
|
# ? Apr 15, 2014 19:01 |
|
Thanks CLAM DOWN, that was what I was looking for, getting ready to try and implement it in now.
|
# ? Apr 15, 2014 19:13 |
|
SniperWoreConverse posted:Try dropping the quotes, that way your variables will be the files you want instead of a string that happens to be the path to the file. (I think, dunno about the -P -x -T stuff) C:\chef-repo>powershell.exe -ExecutionPolicy RemoteSigned -File .git\hooks\pre-commit-hook.ps1 You must provide a value expression on the right-hand side of the '-' operator. At C:\chef-repo\.git\hooks\pre-commit-hook.ps1:58 char:48 + $errors = & $erb $file | $php_bin - <<<< c $file + CategoryInfo : ParserError: ( [], ParentContainsErrorRecordEx ception + FullyQualifiedErrorId : ExpectedValueExpression
|
# ? Apr 15, 2014 19:44 |
drat, getting out of depth for me... maybe you need --%? I think it's just getting parsed wrong I don't know. When you figure it out post what the deal is, this is interesting to me.
|
|
# ? Apr 15, 2014 20:55 |
|
|
# ? May 9, 2024 22:07 |
|
I changed it to code:
|
# ? Apr 15, 2014 21:41 |