Alternate authentication cmdlet
Sometimes it is pretty useful to be able and use alternate credentials in PowerShell command. This can be done by using Get-Credential cmdlet but a downside is that you can not specify password. Instead what will happen every time this cmdlet is ran it will produce a popup box to enter password.
A nice workaround is to store the credentials in encrypted variable such as $cred = Get-Credential Administrator this will initially pop up with authentication box where password is typed in but afterwards you can use $cred variable in your session without need to type it in again.
Run PowerShell command in background and keep control of your session for other tasks
In the situation where we need to run a cmdlet where output will take a while to be produced we can use -asjob switch. This will give us back our prompt to run additional command while our initial query will run in the background. Some of the related cmdlets with which we can control or view jobs are: Get-Job, Receive-Job, Remove-Job, Resume-Job, Start-Job, Stop-Job, Suspend-Job, Wait-Job
Output text in PowerShell
Write-Output
Input some text into powershell
Read-Host
Convert output of query to HTML
This is specifically usefully if desired output needs to be shared for wide audience. All needs to be done is convert it to HTML using ConvertTo-hmtl and output to file using Out-File to write contents into file on web server and your info is readily available for brain consumption.
Import contents of file into PowerShell for processing
Best example for this would be creating multiple users in AD from predefined csv file. We can use Import-CSV cmdlet to take a contents of csv file and pipe it into another cmdlet such as Import-CSV file.csv | New-ADUser. Please note that header of csv file should contain valid AD properties for user. Whichever properties you have, those properties will be created along with a user.
Showing posts with label windows 8. Show all posts
Showing posts with label windows 8. Show all posts
Tuesday, September 17, 2013
Wednesday, July 10, 2013
Microsoft Surface Pro going to sleep every 2 minutes
I have been dealing with this issue for a while now and kept putting it on back burner. Today I just got so pissed off that I decided to have this done now or never. And thank God I did!!
For whatever odd reason surface pro was going to sleep after 2 minutes no matter what my power options were set to. I tried all kinds of settings.
After some research I found that apparently there is a power setting not available in GUI on Microsoft windows 7 and 8 this setting is called "system unattended sleep timeout". If you add following registry setting:[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Power\PowerSettings\238C9FA8-0AAD-41ED-83F4-97BE242C8F20\7bc4a2f9-d8fc-4469-b07b-33eb785aaca0]
"Attributes"=dword:00000002
and go to power setting --> sleep - you will see a new option for "system unattended sleep timeout". Change this setting to your desired value and problems gone!!!!
For whatever odd reason surface pro was going to sleep after 2 minutes no matter what my power options were set to. I tried all kinds of settings.
After some research I found that apparently there is a power setting not available in GUI on Microsoft windows 7 and 8 this setting is called "system unattended sleep timeout". If you add following registry setting:[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Power\PowerSettings\238C9FA8-0AAD-41ED-83F4-97BE242C8F20\7bc4a2f9-d8fc-4469-b07b-33eb785aaca0]
"Attributes"=dword:00000002
and go to power setting --> sleep - you will see a new option for "system unattended sleep timeout". Change this setting to your desired value and problems gone!!!!
Subscribe to:
Posts (Atom)