Optimize Powershell in playbook

29 views
Skip to first unread message

UnknownGnome

unread,
Apr 1, 2020, 11:46:45 PM4/1/20
to Ansible Project
Hello,

I'm trying to get a playbook working that will run the Optimize Powershell script that is here: https://docs.ansible.com/ansible/latest/user_guide/windows_performance.html

The playbook succeeds, but when I check for one of the installed assemblies on a host, it shows as not installed. 

Has anyone ever successfully done this? Is there a better way to get that script to run on all of my hosts (and any new ones as they come up)?


---
nameOptimize Powershell
  hostsall
  gather_factsyes
  tasks:
    - name: Copy script
win_copy
        src"{{fileserver}}\\Open\\Scripts\\Optimize-Powershell.ps1"
        destC:\temp\Optimize-Powershell.ps1
        remote_srcyes
    - nameCopy PsExec
      win_copy:
        src"{{fileserver}}\\Open\\PSTools\\PsExec.exe"
        destc:\temp\psexec.exe
        remote_srcyes
nameRun script through psexec
      win_psexec:
        command"powershell.exe -executionpolicy bypass -noninteractive -nologo -file C:\\temp\\Optimize-Powershell.ps1"
        executableC:\temp\psexec.exe
        elevatedyes
        nobanneryes
        interactiveyes
        username"{{adminuser}}"
        password"{{adminpass}}"

Vivek Kothawale

unread,
Apr 2, 2020, 2:54:37 AM4/2/20
to ansible...@googlegroups.com
Hi 

Can you please provide error msg which you have encountered while running the
Playbook ?

Thanks,
Vivek



--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/d1d1b8af-1e52-4b93-8486-274cce948ce0%40googlegroups.com.

Barry Obie

unread,
Apr 2, 2020, 11:36:19 AM4/2/20
to ansible...@googlegroups.com
Thanks for the reply.The task actually succeeds (shows as changed). But when I go to the host, the assemblies show as not installed. 
The task does have a stderr output though:
Connecting to local system... Starting PSEXESVC service on local system... Connecting with PsExec service on windows-server... Starting powershell.exe on windows-server... powershell.exe exited on windows-server with error code 0.  


This is what the server shows when I check for the installed assembly:
PS C:\Windows\system32> C:\Windows\Microsoft.NET\Framework64\v4.0.30319\ngen.exe display C:\Windows\Microsoft.Net\assembly\GAC_MSIL\Microsoft.PowerShell.ISECommon\v4.0_3.0.0.0__31bf3856ad364e35\Microsoft.PowerShell.ISECommon.dll
Microsoft (R) CLR Native Image Generator - Version 4.8.3761.0
Copyright (c) Microsoft Corporation.  All rights reserved.
Error: The specified assembly is not installed.

You received this message because you are subscribed to a topic in the Google Groups "Ansible Project" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ansible-project/zrGbNVQ9UHU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAA420E8w%3DB1R4notA%3D73RQUY1-zbU5u18WLGjhqBftJ-Xey0jg%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages