|
Been hacking in Powershell lately to automate some bullshit garbage that I can now pass off to somebody who can just click the script and monitor it to make sure nothing failed. See http://z-bo.tumblr.com/post/657962194/optimizing-vba where I have been dabbling in using Powershell to mess with CSV files, using the Excel COM API. It was rough getting used to the API and what idioms worked best, but now that I have done a bit I like it. A cheat sheet for Powershell and Excel would be a nice addition to the Powershell community. I'll bump this thread in the future with some neat Powershell idioms Victor and I came up with about a year and a half ago that have proven rock solid and seriously cut down on lines of code.
|
# ¿ Jun 3, 2010 00:29 |
|
|
# ¿ Apr 27, 2024 20:23 |
|
This might help. Most Microsoft products have a customized version of PowerShell. Exchange's is called Exchange Management Shell You can also use: get-command *queue* get-command *message* in PowerShell to search for Exchange Message Queue-related or Message-related CMDlets. Then, having realized I hit jackpot, I would take get-queue and type it into Google Books. http://www.google.com/search?tbs=bks%3A1&tbo=1&q=get-queue&btnG=Search+Books The first link, Mastering Microsoft Exchange Server 2007 - Page 733, probably gets you as far as I can get you. Note: I am not an Exchange Admin, and figured this all out in 10 mins. What I am teaching you is how to get information on how to do tasks in PowerShell.
|
# ¿ Jun 16, 2010 16:24 |
|
I need some goon help. Mobsync.exe is pegging my CPU at 100% every 5 seconds. I have done just about everything I could find on the Internet to disable this: 1) I've disabled offline files 2) I've tried deleting the USB Device Stack and rebooting so that Vista automatically rebuilds it to fix any device ordering issues 3) I've stopped the Portable Device Enumerator Service and set it to Disabled. 4) I've changed the registry key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WINEVT\Publishers\{b44aec44-38f4-4b59-8 df3-10306abf19b2} property 'Enabled' to 0. 5) I've read that you can disable Execute/Traverse permissions for Everyone on C:\Windows\System\mobsync.exe but am not sure how to do it using PowerShell, and do not want to try a non-PowerShell solution (if I am going to fix this problem, then I refuse to rely on strange Windows programs I have never heard of like xcacl.exe -- it is just one more piece of crap I don't need installed on my computer, and I don't want to install that guys tool either). How do I use set-acl to get rid of mobsync.exe's TrustedInstaller ownership and revoke traverse/execute from Everyone?
|
# ¿ Jun 17, 2010 18:36 |
|
Can you provide a more detailed problem report? For example, can you print out the commands you are using to search your PowerShell environment? What is your path variable? Does it include Exchange? What is the ExecutionPolicy for that path? etc.
|
# ¿ Sep 7, 2010 19:35 |
|
I have an idea and want to throw it out there to get feedback from goons. What do you all think about the idea of writing a PowerShell snap-in that can automatically report on stuff like licenses and installed software on a machine? It seems with WMI we can pretty much automate what a free solution like LANSweeper does, without requiring a client-side executable for it to work. PowerShell would simply use the new remoting features in 2.0 and you'd automatically get ops reports, centralized into perhaps a SQL Server database so we could use SQL Server Reporting Services for building dashboards like LANSweeper has.
|
# ¿ Nov 22, 2010 21:15 |
|
I am in disbelief. I was writing a PowerShell script to dump our database schema to version control and ran into the stupidest bug in the whole world: [PS V2 RTM] Multiple Ambiguous Overloads Wow! This totally wasted my entire afternoon trying to figure out. Also, unfortunately, the workaround in the article doesn't appear to work for me. ALL I WANT TO DO IS DUMP USER DEFINED FUNCTIONS and AGGREGATES!!! This problem doesn't occur for Tables, Views, Triggers and Stored Procedures due to the interface differences between those and UDFs and UDAs. I tried the workaround suggested in the above link, but it was ultimately an epic failure. Right now I am trying to figure out how to use System.Reflection to invoke the right signature in PowerShell, which is gross. Help me. code:
Z-Bo fucked around with this message at 21:27 on May 6, 2011 |
# ¿ May 6, 2011 20:55 |
|
code:
code:
Both say roughly the following error: code:
I've also tried: code:
code:
Z-Bo fucked around with this message at 22:15 on May 6, 2011 |
# ¿ May 6, 2011 22:08 |
|
adaz posted:I can't get it to reproduce the error (also those ; aren't needed ) Thanks for the help thinking through how to better debug this problem. 1) smoObjects.GetType() --> an SMO UrnCollection 2) smoObjects.Count --> 1 Can anyone help me with the reflective invoking of the Scripter.Script(...) method? I also don't understand why System.Reflection.MethodInfo's Invoke(..., ...) method isn't recognized by PowerShell. It may also help to repeat that this appears to be a known PSv2 bug and I need a workaround. Z-Bo fucked around with this message at 15:13 on May 7, 2011 |
# ¿ May 7, 2011 15:07 |
|
This time it is complaining it can't find the Script method on the Scripter object.code:
I am going to code this up in C# just to make sure I don't suddenly completely suck as a programmer.
|
# ¿ May 9, 2011 21:04 |
|
Yup! Actually, debugging a little further thanks to C# made it a little clearer what the issue was. Basically, $udfs was null - I started testing on a new database today and hadn't compiled UDFs or UDAs yet. So this was a totally different problem from the other day. Your code works, it just needs: code:
Edit: Thanks for your help.
|
# ¿ May 9, 2011 21:33 |
|
Thanks. For debugging, on the SQLPSX project I told everyone my general trick fellow goon Victor and I came up with for helping improve PowerShell tracing. PowerShell Tracing module just is too verbose and non-configurable as far as I can tell (compared to say C# or VB.NET or any .NET language). So what we did 2 years ago was this simple idiom: code:
If you scroll back in this thread, I promised to post stuff like this a long, long time ago but was just too lazy. The basic idea is it lets you abstract away the underlying Windows command line program you are wrapping, and provide PowerShell defensive error handling for it. You can also use it to check that the program even exists, and possibly even install it if it doesn't. I need to improve it so that it is generic. The signature should be: code:
quote:I do appreciate that script though, on my List Of Things To Do had been a script to pull off all the stored procedures/functions off a DB and hey now I have one I can post the final version here if people like, but I might put together a polished version for the ISE module in SQLPSX (I am a core contributor to that project, although none of my modules have yet to make it into a release/been reviewed by the team; I am working on a super-awesome profiling and tracing SQLPSX API that hooks into the SqlIse module since the long-term goal of the project is to let you use PowerShell-ISE to replace the god awful SQL Server Management Studio). Z-Bo fucked around with this message at 00:43 on May 10, 2011 |
# ¿ May 10, 2011 00:40 |
|
|
# ¿ Apr 27, 2024 20:23 |
|
Just chiming in to say: Cha-CHING! Googled "Powershell ScriptBlock class" today to go lookup the documentation on how to rewrite my Invoke-Command wrapper, and found somebody else's ConvertTo-ScriptBlock snippet. This is so incredibly useful I felt I had to share it with you all and rejoice.
|
# ¿ May 11, 2011 20:24 |