Quantcast
Channel: Tim Bolton – MCITP – MCTS
Viewing all 28 articles
Browse latest View live

Automate the Windows 2003 Defragmenter Without Paying Extra…

$
0
0

Taken from the Windows IT Pro site  –  http://www.windowsitpro.com/article/windows-shell-bat-and-cmd/automate-the-windows-2003-defragmenter-without-paying-extra.aspx

Excellent Article Daniel..!

Defragmentation is a great way to keep workstations and servers running

at their best performance. Windows Server 2003 comes with a

defragmenter: dfrgntfs.exe. However, you can’t automate this

defragmenter unless you purchase a program such as Diskeeper. I didn’t

have money for such a program in my budget, so I created and scheduled a

batch file named Defrag.bat.

As Listing 1 shows,

Listing 1: Defrag.bat

@Echo Off

defrag.exe c: -f

defrag.exe e: -f

defrag.exe f: -f

Defrag.bat is a simple program. It uses the defragmenter’s command-line

interface (defrag.exe) to run the defragmenter against each drive.

However, I wasn’t happy with Defrag.bat for two reasons. First, I had to

let the batch file run while being left logged on with my administrator

ID. Although I locked the screen for security reasons, I didn’t want to

leave myself logged on all the time. Second, I wanted more automation.

So, I did some digging around and found a means to automate the

procedure. I found that I could use the Windows scheduler but in a

different way that I didn’t know was possible: I could use the AT

command with a batch file.

I created a new batch file, Defrg. bat, which Listing 2 shows.

Listing 2: Defrg.bat

@Echo Off

‘ BEGIN CALLOUT A

Set logfile=f:\defrag.log

‘ END CALLOUT A

Echo Started %date%,%time% >>%logfile%

Echo ———————————– >>%logfile% Echo Defragmenting

C: drive >>%logfile% Echo. >>%logfile% defrag.exe c: -f >>%logfile% Echo

———————————– >>%logfile% Echo Defragmenting E:

drive >>%logfile% Echo. >>%logfile% defrag.exe e: -f >>%logfile% Echo

———————————– >>%logfile% Echo Defragmenting F:

drive >>%logfile% Echo. >>%logfile% defrag.exe f: -f >>%logfile% Echo

———————————– >>%logfile% Echo Finished

%date%,%time% >>%logfile% Echo ———————————–

>>%logfile%

Like Defrag.bat, Defrg.bat runs defrag.exe. However, Defrg.bat has a few

more features than Defrag.bat. I included code that documents when the

defragmenter starts and ends in a log file. I also added code that ports

the defragmenter’s screen output to the same log file (with some titles

in between) to record which drives are being defragmented. That way, I

can easily check to see whether the defragmentation operation ran and

whether any errors occurred.

To use the new script, I log on to the server with my administrator ID,

open a command-shell window, and run command

at 08:00pm /every:M,T,W,Th,F  f:\Defrg.bat

(Although this command appears on several lines here, you would enter it

on one line in the command-shell window.) This command creates a new

scheduled item in Scheduled Tasks that runs Defrg.bat every weeknight at

8 p.m. (which is before our backup runs).

With this new batch file, I don’t need to be logged on for it to run.

Because Defrg.bat is running as a system process, the defragmentation

operation is performed in the background (i.e., no window comes up), but

Task Manager will show that defrag.exe and dfrgntfs.exe are running.

After Defrg.bat finishes, the scheduler will show 0×0 for a successful

execution. However, I always check the log file to make sure no problems

were encountered.

To use Defrg.bat, you simply need to replace f:\defrag.log in the code

at callout A in Listing 2 with the pathname to your log file. The AT

command and batch file work on Windows Server 2003, Windows XP

Professional, and Windows XP Home Edition. I recommend that you make the

batch file a read-only, hidden file. That way, no one can edit it so

that it damages your computers when the scheduled batch runs.

-Daniel L. Gillard



Start – Stop Service with Powershell and Ping

$
0
0

Ran into a request for an OCS Mediation Server that is contacting an OCS Front End Pool over a WAN link.

“We have a remote OCS Mediation server that contacts the OCS Front End Pool over a WAN link. I need that Mediation server to ping those front end servers periodically to verify that the WAN link is up. If the ping on two of the servers fails,  I need it to stop the OCS Mediation service on the mediation server until it can successfully ping the two front end server across the WAN again at which point it would then bring the Service on the Mediation server back up.”

 

With a LOT of assitance from Jeffery Hicks and Claus Thude Nielsen a simple script was created.

I interpreted the need to stop the service if both computers are unreachable and start the service when they are. Plug in your values. $server1=”coredc01″
$server2=”client1″
$service=”spooler”if ((test-connection $server1 -quiet) -AND (test-connection $server2 -quiet)) {
#both servers are reeachable so make sure service is running
get-service $service | where {$_.status -eq “Stopped”} | Start-Service -PassThru
}
else {
#at least one server is unreachable so stop service
write-warning “One of the servers is unreachable”
get-service $service | where {$_.status -eq “Running”} | Stop-Service -PassThru
}

Jeffery Hicks
Windows PowerShell MVPNow Available: Windows PowerShell 2.0: TFM

  In this example the Two Server that are being PINGED are “coredc01″ and “client1″.  The service being stopped and or started is “spooler”.

A scheduled task – set to run as a System Process - can be used to run the PS1 script.

Just for future reference… I simply placed the PS1 file in a temp folder on C:\ for testing. Then I created a scheduled task set to run every minute. In the RUN box (property of the scheduled task) where it was listed -

 

 

C:\temp\restart.ps1 

I added this bit - 

powershell.exe -noexit C:\temp\restart.ps1

It was automatically changed to this -

C:\WINDOWS\system32\WindowsPowerShell\v1.0\powershell.exe -noexit C:\temp\restart.ps1

-noexit keeps the powershell window open so I could see any warnings or MSG. NOTE! If running via scheduled task, the task will have a status of running and will not open a new window until the first one closes.

Also,,, if you are simply removing the network cable to signify a down connection, make sure you have turned off your wireless connection as well. May save you about 20 Min’s of head scratching. <g>

Once I was satisfied with the PS1 working I then removed the -noexit. Works like a charm…
Another example where the PS1 is set to run contniuous -

$server1=”cropfrontend1″
$server2=”corpfrontend2″
$service=”OCS Communication Server Mediation”
do{
if ((test-connection $server1 -quiet) -OR (test-connection $server2 -quiet)) {
#if 1 server is reachable make sure service is running
get-service $service | where {$_.status -eq “Stopped”} | Start-Service -PassThru
}
elseif (!(test-connection $server1 -quiet) -AND (test-connection $server2 -quiet)) {
#if both servers are unreachable stop service
write-warning “Both of the servers are unreachable”
get-service $service | where {$_.status -eq “Running”} | Stop-Service -PassThru
}
start-sleep –s 15
} until ( $true –eq $false)


icacls – changing permissions on files and folders.

$
0
0

Update – Excellent Post  How to Handle NTFS Folder Permissions, Security Descriptors and ACLshttp://blogs.technet.com/b/josebda/archive/2010/11/12/how-to-handle-ntfs-folder-permissions-security-descriptors-and-acls-in-powershell.aspx

I was asked about changing permissions from the root of a drive and all sub-folders.  My immediate reaction was to use the Microsoft tool that replaced cacls – icacls.  Apparently the person that came up with the new name  ”must” have just received their new iPad. <g>

I remembered a Technet article from a friend Gregg Shields – http://technet.microsoft.com/en-us/magazine/2009.07.geekofalltrades.aspx

“Setting permissions for the Marketing folder is slightly different. We use the same permissions flow for the Product folder as we did for the subfolders under Finance, but the Restricted folder will be treated a bit differently. Let’s suppose that folder contains highly secret documents that should be seen by only a very few individuals. Your first thought may be, “A-ha! Here, I’ll use the Deny permissions to prevent the wrong users from accessing this folder!”
But keep in mind that the Deny permissions is actually far too powerful a setting for most situations as it automatically overrides every other permission. Therefore, adding the Deny permission to the Marketing Users group for this folder means that any Restricted users who are also Marketing users would be shut out. A more appropriate solution here is to break the inheritance again and simply eliminate all permissions for the Marketing Users group. Thus, the three icacls command lines required to set the permissions for this structure are”
http://support.microsoft.com/kb/943043

Icacls C:\Shared\Marketing /inheritance:r /grant:r “Finance Users”:(OI)(CI)R /grant:r “File Admins”:(OI)(CI)F

Icacls C:\Shared\Marketing\Product /grant:r “Product Users”:(OI)(CI)M

Icacls C:\Shared\Marketing\Restricted /inheritance:r /grant:r “File Admins”:(OI)(CI)F /grant:r “Restricted Users”:(OI)(CI)M

ALSO see -

The Icacls.exe utility that is included with Windows Server 2003 Service Pack 2 does not support the inheritance bit
Hotfix Download Available

Additionally, you can set the inheritance bit of files or folders by using the updated Icacls.exe utility together with the /inheritance parameter. For more information, see the following sample:
/inheritance:e|d|r
e – enables inheritance
d – disables inheritance and copy the ACEs
r – remove all inherited ACEs

So if you are asking yourself WHAT..?  Like I was, here is some more info on the topic.

“Tim asked me to comment on this question.

You’re on the right path. Funny, but I’m actually about to write a three-part series on icacls for TechTarget.

You need to break the inheritance (/inheritance:r) and then reset the new directly-applied permissions (/grant). The new perms then inherit down because you’re using (OI)(CI), which are “object inherit” and “container inherit”.

So, step one: Break inheritance. Step two: directly set new perm. Step three: Enable inheritance. What’s confusing is that these three steps are all being done in a single line.

Does this help?”

/Greg Shields, MVP – Terminal Services

Tips and Tricks for the Jack-of-all-Trades IT Professional

www.ConcentratedTech.com

The “single line” threw me for a but until I realized what he meant was.  In your single command line you need to break the inheritance first then you will apply the permissions you want to grant accordingly.

So for example -

Step 1 is the /inheritance:r

Step 2 is the /grant Domain\username

Step 3 is the (OI)(CI) F

Thus -

icacls pathname /inheritance:r /grant Domain\username (OI)(CI) F

F = full

If there are any other permissions that exist you could also remove those in the same command by using the :r switch after the grant command.

icacls pathname /inheritance:r /grant:r Domain\username (OI)(CI) F

Many Thanks to Gregg Shields.  I highly anticipate his to be released three-part series on icacls for TechTarget.


Mastering Hyper-V Deployment

New Books!

$
0
0

Learn Windows PowerShell in a Month of Lunches
by Don Jones

Learn Windows PowerShell in a Month of Lunches is an innovative tutorial designed for busy administrators. Author Don Jones has taught thousands of administrators to use PowerShell, and now he’ll teach you, bringing his years of training techniques to a concise, easy-to-follow book. Just set aside one hour a day—lunchtime would be perfect—for an entire month, and you’ll be automating administrative tasks faster than you ever thought possible.

Two new books to add today.  Once again Aidan Finn has released yet another book.

Mastering Windows 7 Deployment



The Great Mark Russinovich has written a thriller, a fictional novel using his experience and knowledge of IT:

Zero Day


“Arab terrorists, with the collusion of Osama bin Laden, are behind the attack, which is supposed to destroy Western civilization. A New York City law firm enlists cyber expert Jeff Aiken to track down a virus that has knocked out the company’s computer network. While working on this problem, Jeff uncovers the larger threat. With the help of “stunningly attractive” Daryl Haugen, an old friend who becomes his love interest, Jeff attempts to warn the authorities, but to little avail”.

You can pre-order the book now on Amazon.com in paper and for Kindle.  The expected RTM is March 15th, 2011.


Powershell for Beginners crossword

$
0
0

I put together a Powershell for Beginners crossword puzzle.  I hope you enjoy it.  I even learned a thing or two while  putting it together.  I will be working on a Clean Up AD Version, thanks to my good friend Mark Minasi, soon.

I also want to thank Jeffery Hicks and Claus Nielsen for urging me to complete this little project.

PDF can be downloaded from link below.

Powershell for Beginners


AD Clean up with Powershell for Beginners.

$
0
0

The questions and answers were developed straight from Microsoft Technet and I have included the link.

Active Directory Cmdlets in Windows PowerShell

Windows PowerShell™ is a task-based command-line shell and scripting language designed especially for system administration. This reference topic for the information technology (IT) professional introduces the 76 Windows PowerShell cmdlets that you can use to manage and administer the Active Directory® directory service and Active Directory Domain Services (AD DS).

http://technet.microsoft.com/en-us/library/ee617195.aspx

The purpose of this crossword was to hopefully introduce some reluctant Administrators to Powershell, especially those that administer Active Directory (AD).

You do not have to be a NASCAR or INDY racer to realize the benefits of being able to drive a car, so what are you waiting for when it comes to learning Powershell?  Powershell will be a mandatory requirement in the very near future, if it is not already in your area.

If you find that Powershell can (will) make your life much easier, then I would highly suggest these links to open your mind and your world to Powershell.

Mark Minasi – Mark Minasi is a senior contributing editor for Windows IT Pro, an MCSE, and the author of more than 30 books, including Mastering Windows Server 2008 R2 (Sybex). He writes and speaks around the world about Windows networking.
http://www.minasi.com/forum/default.asp

Find Users with Get-ADUser - http://www.windowsitpro.com/article/windows-power-tools/getaduser-determine-logged-141189

The Lonely Administrator – Jeffery Hicks

I am certified Microsoft professional, a Microsoft MVP and an IT veteran with almost 20 years of experience, much of it spent as an IT consultant specializing in Windows server technologies.   http://jdhitsolutions.com/blog/

As mentioned – Add WhatIf Support to Your PowerShell Scripts Posted on December 2, 2011 by Jeffery Hicks http://jdhitsolutions.com/blog/2011/12/add-whatif-support-to-your-powershell-scripts/

Concentrated Technology is the brainchild of IT gurus Don Jones and Greg Shields. We offer a number of different products and services, depending on which part of the IT industry you work in.   http://www.concentratedtech.com/

MSFT Scripting Guys – Ed Wilson
Ed is the Microsoft Scripting Guy. He is an expert on scripting technology such as PowerShell, VBScript and WMI. He is the author of over a dozen books.
http://www.scriptingguys.com

Claus Nielsen – Microsoft Powershell MVP

Blog: http://xipher.dk     Public Profile: http://dk.linkedin.com/pub/claus-nielsen/1/2ab/9b1

On the Group Policy / Powershell side of things Jeremy Moskowitz  and Darren Mar-Elia are a MUST reads.

I have included both the crossword puzzles and their answer keys.

AD Clean up with Powershell 1 of 4

AD Clean up with Powershell 1 of 4 KEY

AD Clean up with Powershell 2 of 4

AD Clean up with Powershell 2 of 4 KEY

AD Clean up with Powershell 3 of 4

AD Clean up with Powershell 3 of 4 KEY

AD Clean up with Powershell 4 of 4

AD Clean up with Powershell 4 of 4 KEY


Enforce Plain Text Outlook 2010

$
0
0

There are many companies, both large and small, that would like to require their users to use Plain Text only in their Outlook 2010 Emails.  If you have attempted this you have more than likely set up the appropriate settings available in Group Policy shown below.

I even went as far to ensure this setting on the Exchange 2010 Server Side via Powershell.
Where * is the Default Domain.

Set-RemoteDomain -Identity:* -ContentType MimeText
Get-RemoteDomain -Identity:* | fl - will show the settings.
http://technet.microsoft.com/en-us/library/aa997857.aspx

After finding that the users were still able to select Format Text and change their text to both Rich Text and HTML I decided I had to dig deeper.

I found that I could manually change this feature while logging in with my account but this only affected my logon experience, not the other users.

With the New Message open click  File – Options

Click on Mail – Editor Options

Click on Customize Ribbon – Main Tabs from the drop down – Format Text – Format
Now you can remove Format and those options will no longer appear.

Notice that the Rich Text and HTML options are now gone and the default is Plain Text.

The next step was to reverse the settings placing the Format Text option back in place. Then I made a backup of the entire registry called B4.REG. I then made the changes listed above and once the settings were in place, I created another backup of the registry called Aftr.REG.
My plan was to use WINMerge to find where they change had occurred in the registry to help me find the control ID for the item that I wanted to disable via Group Policy shown below.

As you can see all I need is the Command Bar ID and I will be able to block it. There is even a link listed
http://officeredir.microsoft.com/r/rlidOffice14RibbonControlIDsO14?clid-1033

Thank You Microsoft!

But as you see this link offers no help whatso ever…  Thanks Microsoft… sigh

Working with the two REG files B4.REG and Aftr.REG showed me nothing of any use. I was not able to find a change in the registry that would show me the needed Command Bar ID’s. I also used Process Explorer and Process Monitor, but again nothing that indicated where this was located in the registry where I could manually change a setting.
After endless Google links that provided endless bad information, I came across a link for this app.

Built-in Control Scanner
You use Built-in Controls Scanner to find command bar names and built-in controls IDs.
http://www.add-in-express.com/products/commandbars-controls-ids.php

I installed this on one of my test machines and opened Outlook 2010 and started a new message then selected the Format Text tab.

I then stated the App with Outlook selected.

 THERE WAS MY ANSWER!

In Group Police I updated  -  User Configuration\Administrative Templates\Microsoft Outlook 2010\Disable Items in User Interface\Custom  I entered the Command Bar ID’s along with a description.

Enter the Command Bar ID’s here.  5564 and 5565

I ran Gpupdate /Force on the test machine and reopened Outlook 2010 and started a new email message.  As you can see, the Rich Text and HTML Text options are gone.  This will ensure that they users cannot use this option to bypass policy.

I hope this helps someone that has been trying to configure this setting.  If there is an easier way to do this please post the link here.



Why Should I Learn PowerShell? Real World Example Saves the Day!

Check UserID for Differences

$
0
0

What prompted me to look for this solution was an error we received while trying to run -

Get-CSUser TBOLTON

I received this error -

Management object not found for identity "tbolton".
+ CategoryInfo : InvalidData: (tbolton:UserIdParameter) [Get-CsUser], ManagementException
+ FullyQualifiedErrorId : Identity,Microsoft.Rtc.Management.AD.Cmdlets.GetOcsUserCmdlet
+ PSComputerName : BigDog.ad

The issue turned out to be the Alias Setting on the General Page in Exchange.  For what ever reason the entry there was BOLTONTIM

Today I found what Get-CSUser was keying off of in AD, it was keying off of, “MailNickName”.

# Used To Check for any differences in a UserID

# Example - PS C:\>Check-UserID TBOLTON

Function Check-UserID {
param(
[parameter(Mandatory = $true)]
[String] $UID)
$User=(Get-ADUser $UID -Properties *)
$UserSAM=$User.SamAccountName
$UserName=$User.Name
$UserCN=$User.CN
$UserNickName=$User.MailNickName
# Report if there are differences
if (($UserSAM -eq $UserName) -and ($UserName -eq $UserNickName))
{
"`r`n"
Write-Host -foregroundcolor Green "The UserId"  $UID  "WAS a match"
"`r`n"
Write-Host -foregroundcolor Green "SAM Account:  " $UserSAM
Write-Host -foregroundcolor Green "User Name: -- " $UserName
Write-Host -foregroundcolor Green "CN: --------- " $UserCN
Write-Host -foregroundcolor Green "Mail ALias: - " $UserNickName
"`r`n"
} else {
"`r`n"
     Write-Host -foregroundcolor Red "The UserId"  $UID  "did NOT match"
"`r`n"
Write-Host -foregroundcolor Red "SAM Account:  " $UserSAM
Write-Host -foregroundcolor Red "User Name: -- " $UserName
Write-Host -foregroundcolor Red "CN: --------- " $UserCN
Write-Host -foregroundcolor Red "Mail ALias: - " $UserNickName
"`r`n"
    }
}

——————————————————————————–
In this example my account is intentionally set up wrong while the first account is set up correctly.
 CheckUserID

Working with EPPlus and PowerShell

$
0
0

SqlChow

I recently worked on a requirement, where the end user wanted to convert Excel files into tab-delimited text files. In my head I was like, this is easy: “PowerShell FTW! Yay!”. The reason for the excitement was because we already have two repositories that I know work well with Excel and fit my requirement.

When I started writing the solution, I used Doug’s module because it is as easy as it can get, I was able to write and “test” the code in under 30 minutes. Basically, all I had to do was:

  • Import the module
  • Call ‘ConvertFrom-ExcelSheet’ with the proper parameters

Viola! you can now convert Excel Workbooks with multiple sheets in them.

As much as I hate reinventing the wheel, customers sometimes want you to do stuff that simply does not make any sense. So, I had…

View original post 212 more words


Blocking Mixed Exchange 2013/2016 DAG

$
0
0

EighTwOne (821)

Ex2013 LogoIn the RTM version of Exchange 2016, there’s an issue in that it is allows you to add Exchange 2016 Mailbox servers to Exchange 2013 Database Availability Groups, and vice-versa. As stated in the Release Notes (you do read those?), creating such a mixed version DAG is not supported. In theory, you could even jeopardize your Exchange data, as database structures from both versions are different. This action is also not prevented from the Exchange Admin Center, requiring organizations to have very strict procedures and knowledgeable Exchange administrators.

If you are worried about this situation and you want to prevent accidently adding Mailbox servers to an existing DAG consisting of members of a different Exchange version, there is a way (until this is blocked by the product itself, of course). Cmdlet Extension Agents to the rescue!

The Scripting Agent not only allows you to add additional instructions to existing Exchange…

View original post 263 more words


Creating DNS records

$
0
0

Richard Siddaway's Blog

Following on from my previous post about creating a reverse lookup zone in DNS here’s a function to create records in that zone.

The function takes an IP address and name (of host) and uses Add-DnsServerResourceRecordA to add the record to the forward lookup zone – I use my default AD zone.

The function then splits the IP address. Uses the last octet for the name in the reverse record. Creates the reverse lookup zone from the first 3 octets – notice how the range parameter is used in a decreasing way to specify the order of the octets – to create the reverse lookup zone. The host name and zone are used to create the FQDN of the host.

Add-DnsServerResourceRecordPtr is used to create the reverse (PTR) record.

function new-dnsrecord {
[CmdletBinding()]
param (
[string]$name,
[string]$ipaddress,
[string]$zone = ‘Manticore.org’
)

Add-DnsServerResourceRecordA -Name $name -ZoneName $zone -AllowUpdateAny -IPv4Address $ipaddress

$octs…

View original post 24 more words


Getting Accurate File Versions

$
0
0

Rohn's Blog

I used to think that getting a file version in PowerShell was a fairly simple process:


PS> (Get-Item c:windowssystem32mshtml.dll).VersionInfo.FileVersion
11.00.9600.16410 (winblue_gdr.130923-1706)

There are two issues with that method, though:
1. That property can contain text along with the version
2. It turns out that in Windows Vista and higher, that property might not be coming from the file you think it is.

Issue #1 just means that the property is only good if you’re visually checking the version, or if no comparisons with other versions are necessary.

Issue #2 is the big one for me. What appears to be going on is that the FileVersion string is considered a non-fixed part of the version information, and it is pulled from the MUI resource file (if one exists). This file contains the language specific settings, and it looks like it only gets updated when the major or minor file version of…

View original post 743 more words


DeployImage Module for PowerShell 5

$
0
0

Energized About PowerShell

This is a module I started to put together after the current MVP Summit when I decided I wanted to put together Nano Server.

The current Technet documentation at the time was lacking (it has dramatically improved) but this did not stop my internal need, A different way to deploy using only PowerShell

If you’re curious, you can download the module here on Github or here on the Technet Script Repository. Using PowerShell 5 you can follow the on screen prompts and use the following one liner.

Find-Module DeployImage | Install-Module

What does this module give you?

PowerShell Cmdlets to try and ease dropping a WIM file to a hard drive. It is NOT an MDT replacement. It is just an alternative option for the WIM deployment. The initial intention was just Nano Server but since the process applies to all WIM files you can use it however you…

View original post 527 more words



SQL Code for SCCM Status Message Viewer

$
0
0

FoxDeploy.com

I found myself juggling many different Status Message views in SCCM to try to keep on top of various messages that would arise in one environment.  So I did what anyone would do, and through liberal code-reuse and copy pasting, I reinvented the wheel.

What I’ve created here is based off of two built-in SCCM reports.  The first, Component Messages for the Last 12 Hours, and Count Errors for the last 12 hours (should be reports 80 and 89).

The output is a three-drill down view as seen here.

1 The first page is a collection of a count of messages separates by Warnings and Errors, and then a listing of each grouped by Component ID.

2 Clicking the link icon takes you to a listing of the warnings and errors for that site. I tried to transpose the actual message into the fields, but ran into a number of road blocks…

View original post 39 more words


Creating a Robust Services Function

$
0
0

Fantastic script as usual…

Learn Powershell | Achieve More

I had a time when I needed to know whether or not a service had triggers, which would mean that the StartMode could be Auto (Triggered Start) so that the service might just stop for its own reason and if I happened to have a script that looked for non-running services set to Automatic, then it would be flagged in a report. After some research, I found that I could hop into the registry and look at for the TriggerInfo folder to determine if the service actually had any triggers. If the folder exists, then it has triggers and if not…well you get the idea! SmileSNAGHTML3d8704b

If you work in PowerShell, you know that this is a simple query either through the registry provider or using some .Net types to make the remote registry connection and see if the folder exists.

But that’s not where this ends for me. While searching…

View original post 1,165 more words


PowerShell Summit: CIM Deep Dive

$
0
0

Richard Siddaway's Blog

A big thank you to everyone who attended my Summit pre-conference workshop. The interaction was great and I really enjoyed it even though I was feeling the efffects of my flight the previous day.

One thing we discovered was that good old dependable calc has changed. On a Windows 10 (build 14295 and last couple of builds) its now calculator.exe.

PS> Get-CimInstance -ClassName Win32_Process -Filter “Name LIKE ‘calc%'”

ProcessId Name HandleCount WorkingSetSize VirtualSize
——— —- ———– ————– ———–
1400 Calculator.exe 373 56770560 336953344

On Windows 2012 r2 its still calc.exe which caused a bit of confusion until we realised what was happening

View original post


Breaking CIM sessions

$
0
0

Richard Siddaway's Blog

A CIM session is analogous to a PowerShell remoting session but for CIM based cmdlets – the CIM cmdlets themselves and any CDXML based cmdlets e.g. the networking cmdlets

By default a CIM session uses WSMAN as its transport protocol – the same as remoting. You do have the choice to create a CIM session using DCOM for transport (same as the WMI cmdlets use)

I’ve always maintained that DCOM based sessions could be broken if the remote machine was re-started. This was based on the testing I did when writing PowerShell and WMI.

Some recent information cast doubt on that assertion though. I’ve digging into CIM sessions recently and have what I think is a definitive statement on DCOM based CIM sessions.

If you create a DCOM based CIM session to a machine running PowerShell 2.0 from a machine running PowerShell 3.0 (or PowerShell 4.0 – I haven’t tested…

View original post 249 more words


Building Better PowerShell Dashboards

$
0
0

FoxDeploy.com

First off, YUUGE props to Flynn Bundy for shining lights on the possibility with his post Making DSC Beautiful and @Neeco of HTML5Up.com for these gorgeous HTML5 and CSS templates.

If you check out HTML5up.com, there are a ton of absolutely beautiful templates, for free! (Well, you have to leave a link to the site, unless you pay $20, then you can edit it to your heart’s content).

templates

Some of them REALLY lend themselves well to a dashboard system for consumption of data.

…you know, PowerShell makes an excellent data collection and processing system.

It even has  native HTML capabilities, as we’ve covered previously in our post: Using ConvertTo-HTML and CSS to create useful web reports from PowerShell.  If you’re lost and don’t even know where to start, begin here.  I’ll bet we could make some REALLY cool looking dashboards using PowerShell and Neeco’s templates!

Let’s make a cool…

View original post 1,422 more words


Viewing all 28 articles
Browse latest View live




Latest Images