Showing posts with label powershell. Show all posts
Showing posts with label powershell. Show all posts

Sunday, 11 June 2017

Add-HybridRunbookWorker : Machine is already registered to differnt account

 

If you receive the error: Add-HybridRunbookWorker : Machine is already registered to differnt account

Simply delete the key under: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\HybridRunbookWorker and try the command again.

Friday, 11 September 2015

PowerShell Parameters, Switch vs Boolean. Is Microsoft breaking PowerShell?

I'm going to have a good look at the New-FSRMFileScreenTemplate cmdlet. There is an issue with the "Active" parameter for this cmdlet. Microsoft specifies in the help information that this is a Switch parameter. Switch parameters by design default to $False

The Active parameter is a switch parameter, but it doesn't have a default value.

According to MSDN, the default value should be false:

The online documentation indicates that if the parameter is not specified, the file screen will be passive.

If you run the New-FSRMFileScreenTemplate cmdlet with the Active switch parameter, you get the desired result:

If you run the New-FSRMFileScreenTemplate cmdlet without the Active switch parameter, the file screen is set to Active, huh?

How do I set the thing to Passive?

Well, trying to set it to $False doesn't work

Treating it like a Boolean Parameter does work though.

Anyone know what Microsoft is up to here? I'm seeing this more and more. Having Switch and Boolean Parameters makes sense, but the documentation MUST be correct, otherwise it really makes the parameters hard to use.

References:

Types of Cmdlet Parameters - https://technet.microsoft.com/en-us/library/dd878252(v=vs.85).aspx

New-FsrmFileScreenTemplate - https://technet.microsoft.com/en-us/library/jj900585(v=wps.630).aspx

Parameter Types in PowerShell - http://blogs.msdn.com/b/candede/archive/2010/01/14/parameter-types-in-powershell.aspx

Monday, 22 October 2012

Does Windows RT Support PowerShell?

At a Tech Ed Presentation in the USA, the PowerShell team confirmed that PowerShell is “Available Everywhere”. This includes not only Windows RT, but Server Core and Windows PE.


Saturday, 23 June 2012

PowerShell Profiles and Prompts

To get the path of your PowerShell profile, you can use the built-in $Profile variable. If your profile exists, you can open the profile in notepad using the Invoke-Item cmdlet.

If the profile doesn't exist, as you create it using the New-Item cmdlet. To make sure you can create the file even if part of the path doesn't already exist using the -Force parameter.

Once the profile has been created, you can open it with the Invoke-Item cmdlet.

To customise the PowerShell prompt, you can create a prompt function like I have below.

You could include some Environmental variables in the prompt function to make the PowerShell prompt provide some very useful information, for example:

You can also customise the UI using your profile. This is done by modifying properties of the $Host built-in variable.

Friday, 15 June 2012

PowerShell Version 3 Language Improvements - Part 1

Member Enumeration

In PowerShell Version 2, I found myself quite often running a cmdlet, then piping that cmdlet to Select-Object -Expand PropertyName, for example:


In PowerShell Version 3, the same result can be acheived by running:


Not only is the new syntax easier to use, but it's also quicker, see below. The old method takes 36 seconds to run, the same command using the new method, 16 seconds!


In addition to the improvement listed above. Length and Count properties have been made available to all variables, even if the variable isn't an array, see below:


This is designed to assist in looping logic, so you don't need to determine if an object is just one or many before you go ahead and loop through it. Previously, I got around this using foreach.

PSItem

In PowerShell Version 2, You had to use the $_ variable to represent the current pipeline object. In PowerShell Version 3, you can use the $PSItem alias, which is much easier on the eye/fingers.

Tuesday, 5 June 2012

PowerShell Version 3–Let’s Go!

Let’s make sure we are running version 3.0, by checking the $Host variable:

PowerShell starts up faster than ever, especially the ISE, it is sooo much faster when running Version 3.

The big changes in the ISE from version 2 to version 3 are:

  • IntelliSense – Very awesome!
  • Visualise the cmdlets in the right pane and either run them or insert them (Also available with Show-Command)
  • Snippets (more info below)

Snippets

You can add a snippet using the New-ISESnippet cmdlet (shown below). You can get a list of the snippets using Get-ISESnippet. You can add a Snippet to your script using Crtl+J or by right-clicking in the Script Editor in the ISE.

As expected, the snippet persisted across ISE Sessions!

That’ll make script creation even faster

Sunday, 1 April 2012

How to: Install PowerShell Web Access on Windows Server 2012 (8)

Quickly Install using PowerShell


If you want to really quickly install PowerShell Web Access to test the functionality in a lab environment, you can run the following commands:
  1. Add-WindowsFeature WindowsPowerShellWebAccess
  2. Install-PswaWebApplication -UseTestCertificate
  3. Add-PswaAuthorizationRule * * *
  4. Start your browser and navigate to https://servername/pswa/

Install Manually Using Server Manager

  1. Fire up Server Manager and select Manage –> Add Roles and Features
  2. Click Next on the Before you begin step
     
  3. Select Role-based or feature-based Installation and click Next
     
  4. Select the Target server from the Server Pool and click Next
     
  5. On the Select Server Roles step, click Next. PowerShell Web Access is a feature so we will skip this step.
     
  6. On the Features step, select PowerShell Web Access. When prompted click Add Features to add required roles and features and click Next
     
     
     
  7. On the IIS role step and the IIS Role Services steps, click Next (Next, Next)
     
     
  8. At the Confirm step, click Install
     
  9. Wait for the installation to complete, or click Close
     
  10. If you do click close before the installation completes, you can monitor the task from the notification icon within Server Manager
     
  11. Configure the web application by running the Install-PSwaWebApplication cmdlet shown below.
    Please note: You may prefer to change the web application name or just leave that parameter out and the default will be pswa.
     
  12. Configure an Authorisation Rule for the built-in Administrator account using the  Add-PswaAuthorisationRule cmdlet
     
  13. Try it out! https://localhost/myWebApp/
     
     

Sunday, 18 March 2012

Hands on with: Windows Server 2012 (8) –Hyper-V PowerShell Module

I recently upgraded my home lab Hyper-V server to Windows Server 8. Then I installed all the Hyper-V associated roles and role services including the new Hyper-V PowerShell cmdlets.
Then I fired up PowerShell, imported the Hyper-V module and retrieved a list of commands available in the new module.

Then I decided to play around with the harmless get-* cmdlets, starting with get-vm.

Alright, now for something equally harmless. Let’s try changing the notes for the VM called “Arche”

What’s surprising is that the Hyper-V manager is immediately updated with the new data. I thought I would have to do a refresh to pick up the changes.

Alright, enough with the easy stuff, let’s create a new VM! Here’s the details:
  • Name: DC1
  • Start-up RAM: 512MB (Dynamic)
  • 1 HDD: 40GB
  • Other hardware: CDROM, Network
A couple of gotchas:
  • VHDs in Windows Server 8 now have the VHDX extension, old habits!
  • The ComputerName parameter is used to specify which Hyper-V host to host the VM on. That’s actually pretty standard in PowerShell and it shouldn’t have got me!

I now need to set the DVD drive in the VM to the Windows Server 8 DVD ISO and start the VM:



That’s it for now!

Saturday, 3 March 2012

Hands on with the Windows Server 2012 (8) Beta – Core Installation

I ran up a default installation, which happens to be Server Core, no Windows Explorer!
After completing the install, you will be required to change the Administrator password:


Then you will be presented with the user interface:

The first command I tried was “PowerShell” and it worked. Just like in the previous version, PowerShell is available on Server core. Time to familiarise myself with some of the new cmdlets.

If you remember oobe.exe from Windows Server 2008 (also called “Initial Configuration”), it provided a list of commonly configured settings on a new server. I will use it as a guide to configure Windows Server 8 Core.
Alright, first on the list, setting the product key.

Wow! Honestly, could that be any easier?
Let’s try and set the date/time next:

Also very easy, there could still be a PowerShell cmdlet for this, but the Control Panel applet will do for now…
Next, lets try and rename the computer.

Is that easier than using the GUI? I think so! Ok, restart time.
Logon screen:

Alright, all logged in, back to PowerShell.
Alright, let’s enable remote desktop… Remote Desktop really isn’t needed on Window Server these days, but I want to see how to enable it regardless! Remote Shell is where it’s at!

Huh? None of those cmdlets scream “enable remote desktop”. Alright let’s use sconfig!

Turns out there are a few other things I might want to set in sconfig, I will do those and then exit.
best-it-exam-    | for-our-work-    | hottst-on-sale-    | it-sale-    | tast-dumps-us-    | test-king-number-    | pass-do-it-    | just-do-it-    | pass-with-us-    | passresults-everything-    | passtutor-our-dumps-    | realtests-us-exam-    | latest-update-source-for-    | cbtnuggets-sale-exam    | experts-revised-exam    | certguide-sale-exam    | test4actual-sale-exam    | get-well-prepared-    | certkiller-sale-exam    | buy-discount-dumps    | how-to-get-prepared-for-the    | in-an-easy-way    | brain-dumps-sale    | with-pass-exam-guarantee    | accurate-study-material    | at-first-try    | 100%-successful-rate    | get-certification-easily    | material-provider-exam    | real-exam-practice    | with-pass-score-guarantee    | certification-material-provider    | for-certification-professionals    | get-your-certification-successfully    | 100%-Pass-Rate    | in-pdf-file    | practice-exam-for    | it-study-guides    | study-material-sku    | study-guide-pdf    | prep-guide-demo    | certification-material-id    | actual-tests-demo    | brain-demos-test    | best-pdf-download    | our-certification-material    | best-practice-test    | leading-provider-on    | this-course-is-about    | the-most-reliable    | high-pass-rate-of    | money-back-guarantee    | high-pass-rate-demo    | recenty-updated-key    | only-for-students-free-download    | courseware-plus-kit-for    | accurate-answers-of    | the-most-reliable-id    | provide-training-for    | welcome-to-buy    | material-for-success-pass    | provide-free-support    | best-book-for-pass    | accuracy-of-the-answers    | pass-guarantee-id    |
http://forensics.sch.ac.kr/    | http://forensics.sch.ac.kr/    |