Monday, January 9, 2012

Change Service Start Mode the PowerShell Way

 

 

When you list services with Get-Service, you will find that a lot of properties may seem to be missing. You can still set such properties when you pipe a service to Set-Service. The following code will change the start mode of the Spooler service (provided you have sufficient privileges):

Get-Service spooler | Set-Service -StartupType Automatic

 

PowerTip of the Day, from PowerShell.com

 

Thanks

Tuesday, December 13, 2011

Writing Registry Key Default Values

 

PowerTip of the Day, from PowerShell.com:

 

If you need to set the default value for a Registry Key, you can  use either of these approaches:

Set-ItemProperty -Path HKCU:\Software\Somekey -Name ‘(Default)’ -Value MyValue

Or, you can just do this:

Set-Item -Path HKCU:\Software\Somekey -Value MyValue

 

thanks

Asking for Credentials

 

PowerTip of the Day, from PowerShell.com:

When you write functions that accept credentials as parameters, add a transformation attribute! This way, the user can either submit a credential object (for example, a credential supplied from Get-Credential), or simply a user name as string. The transformation attribute will then convert this string automagically into a credential and ask for a password.

function do-something {

param(

[System.Management.Automation.Credential()]

$Credential

)

'$Credential now holds a valid credential object'

$Credential

}

When you run do-something without parameters, it will automatically invoke the credentials dialog.

How to List Registry Hives

 

PowerTip of the Day, from PowerShell.com:

Use the provider name instead of a drive name when you need to get a list of all Registry Hives:

Dir Registry::

thanks

aman

My PowerShell Story: PowerShell and I

 

hi,

Thanks to http://www.powershellmagazine.com they just upload my powershell story yesterday.

13-12-2011 18-47-14

you can read the complete story here:  http://www.powershellmagazine.com/2011/12/12/powershell-and-i/

thanks

aman

Friday, December 2, 2011

Print All PDF Files in Folders using PowerShell

 

PowerTip of the Day, from PowerShell.com:

Try this one-liner if you need to print out all PDF documents you have stored in one folder:

Dir c:\myfolder\*.pdf | Foreach-Object { Start-Process -FilePath $_.FullName – Verb Print }

 


Thanks to www.powershell.com

Determining Service Start Modes using PowerShell

 

PowerTip of the Day, from PowerShell.com:

 

By using WMI, you can enumerate the start mode that you want your services to use. To get a list of all services, try this:

Get-WMIObject Win32_Service | Select-Object Name, StartMode

If you want to find out the start mode of one specific service, try this instead:

([wmi]'Win32_Service.Name="Spooler"').StartMode

Thanks to www.powershell.com