I ran a quick test with this and received the following error.
- The term 'New-Item -ItemType directory -Path $homeFolderPath -ErrorAction Stop' is not recognized as the name of a cmdlet, function, script file or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
I have this running as an action and it runs after I've defined the terminal services home directory.