คำถาม MDT 2010 Running Powershell script does..... nothing

  • Thursday, October 18, 2012 1:53 AM
     
      Has Code

    My company has a setup guide for Windows 7 with various tweaks in it that I was hoping to integrate in to the deployment process. I have tried the following:

    1. Create a LocalGPO pack - This worked for some of the settings but not all the settings. That and it prevented the user from making changes later.

    2. Unattend.xml - I found a few tweaks that can be done here. Some of my changes stick, some do not.

    3. Powershell script - I have spent hours isolating all the necessary registry keys to make the tweaks happen. Here is the script:

    #Set-ExecutionPolicy Unrestricted
    
    #Folder Options
    New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name HideFileExt -PropertyType Binary -Value 0 -Force
    New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name DontPrettyPath -PropertyType Binary -Value 0 -Force
    New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name AlwaysShowMenus -PropertyType Binary -Value 1 -Force
    New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer -Name CabinetState -Force
    New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\CabinetState -Name FullPath -PropertyType Binary -Value 1 -Force
    
    #Start Menu
    New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name Start_ShowDownloads -PropertyType Binary -Value 1 -Force
    New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name Start_NotifyNewApps -PropertyType Binary -Value 0 -Force
    New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name Start_ShowSetProgramAccessAndDefaults -PropertyType Binary -Value 0 -Force
    New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name Start_ShowMyMusic -PropertyType Binary -Value 0 -Force
    New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name Start_ShowRecentDocs -PropertyType Binary -Value 1 -Force
    New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name Start_ShowRun -PropertyType Binary -Value 1 -Force
    New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name Start_PowerButtonAction -PropertyType Binary -Value 2 -Force
    
    #Notification Area and Action Center
    New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer -Name EnableAutoTray -PropertyType Binary -Value 0 -Force
    New-Item -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies -Name Explorer -Force
    New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer -Name HideSCAHealth -PropertyType Binary -Value 1 -Force
    
    #Control Panel
    New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer -Name ControlPanel -Force
    New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel -Name AllItemsIconView -PropertyType Binary -Value 1 -Force
    New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel -Name StartupPage -PropertyType Binary -Value 1 -Force
    
    #User Access Control
    New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System -Name ConsentPromptBehaviorAdmin -PropertyType Binary -Value 0 -Force
    New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System -Name EnableLUA -PropertyType Binary -Value 0 -Force
    New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System -Name PromptOnSecureDesktop -PropertyType Binary -Value 0 -Force
    
    #Windows Updates
    New-Item -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion -Name WindowsUpdate -Force
    New-Item -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate -Name "Auto Update" -Force
    New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update" -Name AUOptions -PropertyType Binary -Value 3 -Force
    New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows" -Name WindowsUpdate -Force
    New-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\Auto Update" -Name ScheduledInstallDay -PropertyType Binary -Value 0 -Force
    New-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\Auto Update" -Name ScheduledInstallTime -PropertyType Binary -Value 9 -Force
    
    #Remote Desktop
    New-ItemProperty -Path "HKLM:\SYSTEM\ControlSet001\Control\Terminal Server" -Name fDenyTSConnections -PropertyType Binary -Value 0 -Force
    New-ItemProperty -Path "HKLM:\SYSTEM\ControlSet001\Control\Terminal Server\WinStations\RDP-Tcp" -Name UserAuthentication -PropertyType Binary -Value 1 -Force
    New-ItemProperty -Path "HKLM:\SYSTEM\ControlSet001\Control\Terminal Server" -Name fAllowToGetHelp -PropertyType Binary -Value 0 -Force
    New-ItemProperty -Path "HKLM:\SYSTEM\ControlSet002\Control\Terminal Server" -Name fAllowToGetHelp -PropertyType Binary -Value 0 -Force
    New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server" -Name fAllowToGetHelp -PropertyType Binary -Value 0 -Force
    New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Remote Assistance" -Name fAllowToGetHelp -PropertyType Binary -Value 0 -Force
    New-ItemProperty -Path "HKLM:\SYSTEM\ControlSet001\Control\Remote Assistance" -Name fAllowToGetHelp -PropertyType Binary -Value 0 -Force
    New-ItemProperty -Path "HKLM:\SYSTEM\ControlSet002\Control\Remote Assistance" -Name fAllowToGetHelp -PropertyType Binary -Value 0 -Force
    
    #Windows Firewall
    New-Item -Path HKLM:\SOFTWARE\Policies\Microsoft -Name WindowsFirewall -Force
    New-Item -Path HKLM:\SOFTWARE\Policies\Microsoft\WindowsFirewall -Name StandardProfiles -Force
    New-Item -Path HKLM:\SOFTWARE\Policies\Microsoft\WindowsFirewall -Name DomainProfiles -Force
    New-Item -Path HKLM:\SOFTWARE\Policies\Microsoft\WindowsFirewall -Name PublicProfiles -Force
    New-Item -Path HKLM:\SOFTWARE\Policies\Microsoft\WindowsFirewall -Name PrivateProfiles -Force
    New-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\WindowsFirewall\StandardProfiles -Name EnableFirewall -PropertyType Binary -Value 0 -Force
    New-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\WindowsFirewall\DomainProfiles -Name EnableFirewall -PropertyType Binary -Value 0 -Force
    New-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\WindowsFirewall\PublicProfiles -Name EnableFirewall -PropertyType Binary -Value 0 -Force
    New-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\WindowsFirewall\PrivateProfiles -Name EnableFirewall -PropertyType Binary -Value 0 -Force
    
    #IE Settings not handled by unattended.xml
    New-Item -Path "HKCU:\Software\Microsoft\Internet Explorer\SearchScopes" -Name "{E654518E-3688-45C9-A3F3-0FD51CADB782}" -Force 
    New-ItemProperty -Path "HKCU:\Software\Microsoft\Internet Explorer\SearchScopes" -Name DefaultScope -PropertyType String -Value "{E654518E-3688-45C9-A3F3-0FD51CADB782}" -Force
    New-ItemProperty -Path "HKCU:\Software\Microsoft\Internet Explorer\SearchScopes\{E654518E-3688-45C9-A3F3-0FD51CADB782}" -Name DisplayName -PropertyType String -Value "Google" -Force
    New-ItemProperty -Path "HKCU:\Software\Microsoft\Internet Explorer\SearchScopes\{E654518E-3688-45C9-A3F3-0FD51CADB782}" -Name URL -PropertyType String -Value "http://www.google.com/search?q={searchTerms}&sourceid=ie7&rls=com.microsoft:{language}:{referrer:source}&ie={inputEncoding?}&oe={outputEncoding?}" -Force
    New-ItemProperty -Path "HKCU:\Software\Microsoft\Internet Explorer\SearchScopes\{E654518E-3688-45C9-A3F3-0FD51CADB782}" -Name ShowSearchSuggestions -PropertyType Binary -Value 1 -Force
    New-ItemProperty -Path "HKCU:\Software\Microsoft\Internet Explorer\SearchScopes\{E654518E-3688-45C9-A3F3-0FD51CADB782}" -Name SuggestionsURL -PropertyType String -Value "http://clients5.google.com/complete/search?q={searchTerms}&client=ie8&mw={ie:maxWidth}&sh={ie:sectionHeight}&rh={ie:rowHeight}&inputencoding={inputEncoding}&outputencoding={outputEncoding}" -Force
    New-ItemProperty -Path "HKCU:\Software\Microsoft\Internet Explorer\SearchScopes\{E654518E-3688-45C9-A3F3-0FD51CADB782}" -Name OSDFileURL -PropertyType String -Value "http://www.iegallery.com/en-us/AddOns/DownloadAddOn?resourceId=813" -Force
    New-ItemProperty -Path "HKCU:\Software\Microsoft\Internet Explorer\SearchScopes\{E654518E-3688-45C9-A3F3-0FD51CADB782}" -Name FaviconURL -PropertyType String -Value "http://www.google.com/favicon.ico" -Force
    New-ItemProperty -Path "HKCU:\Software\Microsoft\Internet Explorer\SearchScopes\{E654518E-3688-45C9-A3F3-0FD51CADB782}" -Name FaviconPath -PropertyType String -Value "C:\Users\Administrator\AppData\LocalLow\Microsoft\Internet Explorer\Services\search_{E654518E-3688-45C9-A3F3-0FD51CADB782}.ico" -Force
    
    #Windows Media Player
    New-Item -Path HKCU:\Software\Microsoft\MediaPlayer\Setup -Name UserOptions -Force
    New-ItemProperty HKCU:\Software\Microsoft\MediaPlayer\Setup\UserOptions -Name DesktopShortcut -PropertyType String -Value "no" -Force
    New-ItemProperty HKCU:\Software\Microsoft\MediaPlayer\Preferences -Name EnableWMPDMR -PropertyType Binary -Value 0 -Force
    New-ItemProperty HKCU:\Software\Microsoft\MediaPlayer\Preferences -Name FirstRun -PropertyType Binary -Value 1 -Force
    New-ItemProperty HKCU:\Software\Microsoft\MediaPlayer\Preferences -Name ShowAppTitlebarVTen -PropertyType Binary -Value 1 -Force
    New-ItemProperty HKCU:\Software\Microsoft\MediaPlayer\Preferences -Name AcceptedPrivacyStatement -PropertyType Binary -Value 1 -Force
    New-ItemProperty HKCU:\Software\Microsoft\MediaPlayer\Preferences -Name UseUDP -PropertyType Binary -Value 0 -Force
    New-ItemProperty HKCU:\Software\Microsoft\MediaPlayer\Preferences -Name UseMulticast -PropertyType Binary -Value 1 -Force
    New-ItemProperty HKCU:\Software\Microsoft\MediaPlayer\Preferences -Name UseTCP -PropertyType Binary -Value 0 -Force
    New-ItemProperty HKCU:\Software\Microsoft\MediaPlayer\Preferences -Name UseHTTP -PropertyType Binary -Value 1 -Force
    New-Item HKCU:\Software\Microsoft\MediaPlayer\Setup -Name UserOptions -Force
    New-ItemProperty HKCU:\Software\Microsoft\MediaPlayer\Setup\UserOptions -Name DesktopShortcut -PropertyType String -Value "no" -Force
    

    I placed the "Run Powershell script item in my task list under State Restore, just before Imaging. I also added a Restart Computer item just before Imaging.  Here is the actual call:

    Powershell Script
    \\deploy\deploymentshare$\CustomScripts\RegKeys.ps1
    
    Parameters
    -ExecutionPolicy Unrestricted -NoProfile

    I check the logs and everything runs with no errors, some of the settings seem to apply but others do not. The keys get inserted but they don't seem to take effect.
    Things that I set but don't work

    1. Disable UAC

    2. Disable Remote Assistance (This I don't get it is turned off in unattend.xml and my script!)

    3. Windows Update settings

    4. Show all notifications

    5. Disable Action Center

    6. Show Control Panel list as small icons

    Anyone have any advice? How are you setting up your default profile. It stinks that MS took away the ease of setting up the Default Profile.

All Replies

  • Friday, October 19, 2012 3:24 PM
     
     
    I figured it out. I had the wrong PropertType on some of these keys. I can post my final script if anyone is interested.