title: Powershell .ToUpper and remove spaces
body: <p>After a lot of blood, sweat, tears, and amazing assistance from folks on these boards I finally have my code working, but I need a little help with trimming and capitalizing. I sort of understand how to change something after it is already created, but I'd rather have it converted before it is committed. </p>
  
  <p>Is this the correct syntax:</p>
  
  <pre><code>#Create Security Groups
      $GroupParams1= @{
          'Name' = "FS-$NAME-RW".ToUpper
          'SamAccountName' = "FS-$NAME-RW".ToUpper
          'GroupCategory' = "Security"
          'GroupScope' = "Global"
          'DisplayName' = "$NAME Read-Write Access"
          'Path' = "OU=$LOCATION,OU=FILE SHARE GROUPS,OU=Security Groups,DC=esg,DC=intl"
      'Description' = "Members of this group have read-write access to $Path."
  }
  </code></pre>
  
  <p>If that is correct, how do I remove the spaces that MIGHT be added due to the $Name Input? </p>
  
  <p>In this instance I want to be able to have a folder created called "Test Share 123," but I'm wanting the AD group created by this to be called "FS-TESTSHARE123-R" and "FS-TESTSHARE123-RW" instead of "FS-Test Share 123-R." </p>
  
  <p>Also, any other suggestions on my script? </p>
  
  <pre><code>$Parent = read-host -prompt "Enter full parent path that will contain the new folder (ie. \\eccofs01\Groups\ECCO IT\)"
  $Name = read-host -prompt "Enter New Folder Name."
  $Path = "$($parent)$($Name)"
  $Location = read-host -prompt "Enter the AD Security Group Location (i.e. Global, Americas, Europe, Asia Pacific)"
  
  Import-Module ActiveDirectory
  
  #Create Security Groups
  $GroupParams1= @{
      'Name' = "FS-$NAME-RW" 
      'SamAccountName' = "FS-$NAME-RW" 
      'GroupCategory' = "Security"
      'GroupScope' = "Global"
      'DisplayName' = "$NAME Read-Write Access"
      'Path' = "OU=$LOCATION,OU=FILE SHARE GROUPS,OU=Security Groups,DC=esg,DC=intl"
      'Description' = "Members of this group have read-write access to $Path."
  }
  
  New-ADGroup @GroupParams1
  
  $GroupParams2= @{
      'Name' = "FS-$NAME-R" 
      'SamAccountName' = "FS-$NAME-R" 
      'GroupCategory' = "Security"
      'GroupScope' = "Global"
      'DisplayName' = "$NAME Read-Write Access"
      'Path' = "OU=$LOCATION,OU=FILE SHARE GROUPS,OU=Security Groups,DC=esg,DC=intl"
      'Description' = "Members of this group have read access to $Path"
  }
  
  New-ADGroup @GroupParams2
  
  # Create New Folder
  New-Item -Path $Path -ItemType Directory
  
  #Create All ACEs (permission sets) and Set ACL on the new folder
  function New-Ace {
    [CmdletBinding()]
    Param(
      [Parameter(Mandatory=$true, Position=0)]
      [Security.Principal.NTAccount]$Account,
      [Parameter(Mandatory=$false, Position=1)]
      [Security.AccessControl.FileSystemRights]$Permissions = 'ReadAndExecute',
      [Parameter(Mandatory=$false, Position=2)]
      [Security.AccessControl.InheritanceFlags]$InheritanceFlags = 'ContainerInherit,ObjectInherit',
      [Parameter(Mandatory=$false, Position=3)]
      [Security.AccessControl.PropagationFlags]$PropagationFlags = 'None',
      [Parameter(Mandatory=$false, Position=4)]
      [Security.AccessControl.AccessControlType]$Type = 'Allow'
    )
  
    New-Object Security.AccessControl.FileSystemAccessRule(
      $Account, $Permissions, $InheritanceFlags, $PropagationFlags, $Type
    )
  }
  
  $domain = 'ESG.INTL'
  
  $administrators = ([wmi]"Win32_Sid.Sid='S-1-5-32-544'").AccountName
  
  $acl = Get-Acl $path
  
  $administrators, "$domain\Domain Admins" | ForEach-Object {
    $acl.AddAccessRule((New-Ace $_ 'FullControl'))
  }
  $acl.AddAccessRule((New-Ace "$domain\FS-$NAME-RW" 'Modify'))
  $acl.AddAccessRule((New-Ace "$domain\FS-$NAME-R" 'ReadAndExecute'))
  
  Set-Acl $path $acl
  </code></pre>