I still find Custom Views useful when troubleshooting on individual workstations, and I’d recently been wondering if it was possible to push them out via GPP or similar. I started creating some views manually, as a test, but it was taking too long.
I’d recently been working on implementing Palantir’s WEF/WEC setup, and wondered whether I could leverage their legwork to automate the creation of these custom views.
The script I came up with took a fraction of the time to write, as opposed to the manual method. It does the following:
- Downloads the Palantir ‘windows-event-forwarding’ repo in ZIP format into a temporary folder
- Extracts the Event Log query out of each file in the ‘wef-subscriptions’ folder, and
turns it into an appropriately-named custom Event Viewer view (XML) file in %PROGRAMDATA%\Microsoft\Event Viewer\Views
I love how simple PowerShell makes it to work with XML.
The script needs to be run as an admin in order to create the view files in %PROGRAMDATA%, unless you change the output path in the $templateStoragePath variable. It’ll also need to be able to connect to the Internet to download the ZIP file from GitHub.
I’ve started storing my scripts in my PowerShell GitHub repo rather than as Github Gists, and it’s harder to embed them on wordpress.com. View the code via the link below:
I received a helpdesk ticket today from a user who was having trouble opening an Excel workbook.
I was recently working with a report template where a numbered Heading 1 had a colour and size assigned to the actual number style. This was then causing problems on the table of contents because the number’s style was showing up there too.
The problem is though, it’s impossible to remove the formatting on that number via the UI in Word. By default, the colour is set to “No Color”, but it’s impossible to go back to that setting once a colour has been chosen.
I didn’t want to re-create the entire document as it had macros embedded, and also had a lot of work done already. Luckily, all of this information is stored in XML format, so it’s not too hard to find.
To remove this style information from the number, do the following with a backup of your file.
- Rename the file extension to .zip (I usually just append .zip to the existing filename)
- Copy out the Word folder from within the zip file to somewhere temporary
- Open numbering.xml from the unzipped word folder with something like XML Notepad
- Search for the name of your style. In my case, it was “Heading1” (note the lack of a space between “Heading” and “1”. The style is actually called “Heading 1” in Word:
- Once you find that style, drill down to the w:rPr node. You can see here that a style and colour is defined for the numbering associated with Heading 1
- Remove everything under w:rPr except for w:rFonts->w:hint (I’m sure you could remove this too, but it was there by default for other styles)
- Save the XML file
- Copy the XML file back into the word folder in the zip file
- Rename the file extension back to what it originally was. In my case, it was .docm
- Open the file in Word, and inspect the result. Hopefully, it succeeds for you as it did for me:
Remember: Do this with a backup copy of your file in case you somehow manage to corrupt it.