Popular Posts

Monday, April 29, 2019

Install Ansible on control node

To install Ansible on the control node, run sudo yum install ansible.

Configure the 'ansible' user on the control node for ssh shared key access to managed nodes. 

Do not use a passphrase for the key pair.

  1. To create a keypair for the ansible user on the control host, run the following:
    • sudo su - ansible
    • ssh-keygen (accept all defaults: press enter for each prompt)
  2. Copy the public key to both node1 and node2.
  3. As the ansible user on the control host:
    • ssh-copy-id node1 (accept the host key if prompted, authenticate as ansible user)
    • ssh-copy-id node2 (accept the host key if prompted, authenticate as ansible user)


Create a simple Ansible inventory on the control node in /home/ansible/inventory containing node1 and node2.

  • On the control host: 
    1. sudo su - ansible (if not already ansible user)
    2. touch /home/ansible/inventory
    3. echo "node1" >> /home/ansible/inventory
    4. echo "node2" >> /home/ansible/inventory


Configure sudo access for Ansible on node1 and node2 such that Ansible may use sudo for any command with no password prompt.

  • Log in to node1 and edit the sudoers file to contain appropriate access for the ansible user:
    • sudo visudo
    • Add the following line to the file and save:
      ansible    ALL=(ALL)       NOPASSWD: ALL
  • Repeate these steps for node2.


Verify each managed node is able to be accessed by Ansible from the control node using the ping module. Redirect the output of a successful command to /home/ansible/output.

  • To verify each node, run the following as the ansible user from the control host:
    • ansible -i /home/ansible/inventory node1 -m ping
    • ansible -i /home/ansible/inventory node2 -m ping
  • To redirect output of a successful command to /home/ansible/output:
    • ansible -i /home/ansible/inventory node1 -m ping > /home/ansible/output

Wednesday, November 7, 2018

Attempting to perform the InitializeDefaultDrives operation on the 'FileSystem' provider failed.





Here are the symptoms:
  1.      Cannot find C and D etc. drives in windows/file explorer
  2.      Unable to disconnect the mapped drive (etc K drive) – error message is “This network connection does not exist”
  3.      Net use command does not list this drive
  4.      Noticed group policy configured for both machine and user to map this drive during startup and login respectively
  5.      A script was also placed in C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup to configure the mapped drive at startup

Actions taken:
6.      1. Disabled group policy stated in #3 above
7.      2. Removed the script from startup folder in #4 above
   3. Rebooted and issue was fixed
   4. Placed the script back on startup folder and rebooted again which did not re-produce the error.
   5. Furthermore, HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\ Explorer   Value: NoDrives was set to 0 to show all drives.

Sunday, September 2, 2018

PowerShell scripts to run Config Mgr actions for Machine policy update and software update cycles and check number of missing updates



Run CM actions script

function RecurssiveTimer([int]$time){

if ($time -eq 0){
return
}

write-host "$time*" -NoNewline

$time--

Start-sleep -s 60

RecurssiveTimer -time $time

}


function Run-CMactions{

Write-Host "##### Running Configuration Manager Client Actions #####"

try{

Write-Host "## Running Machine Policy Retrieval & Eval. Cycle ##"

Invoke-WMIMethod -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule “{00000000-0000-0000-0000-000000000021}” | Out-null

Write-Host "Sleeping for 15 minutes..."

RecurssiveTimer -time 15

try{

Write-Host "## Running Software Updates Deployment Eval. Cycle ##"

Invoke-WMIMethod -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule “{00000000-0000-0000-0000-000000000108}” | Out-null

Write-Host "## Running Software Updates Scan Cycle ##"

Invoke-WMIMethod -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule “{00000000-0000-0000-0000-000000000113}” | Out-null

Write-Host "Sleeping for 5 minutes..."

RecurssiveTimer -time 5

return 0

}

catch{

throw

Write-Host -BackgroundColor Red "Error Running Software Update Cycles"

return -1

}

}

catch{

throw
Write-Host -BackgroundColor Red "Error Running Machine Policy Retrieval & Eval. Cycle"

return -1

}

}


Run-CMactions



Check compliance script

write-host "Checking compliance"

$Deployments = Get-WmiObject -Namespace root\ccm\SoftwareUpdates\DeploymentAgent -Query "Select * from CCM_AssignmentCompliance" -ErrorAction SilentlyContinue

if($Deployments){

$Updatestargeted = Get-WmiObject -Namespace root\ccm\SoftwareUpdates\DeploymentAgent -Query "Select * from CCM_TargetedUpdateEX1 where UpdateState = 0" -ErrorAction Stop

if($Updatestargeted){

$iMissing=0
$Updatestargeted | ForEach-Object {

$iMissing++

}
write-host -BackgroundColor Red "Number of Missing Updates: $iMissing"
write-host $iMissing
return $iMissing

}

else {

Write-Host -BackgroundColor Green -ForegroundColor Black "No Missing Software Updates Found"
return 0

}

}

else{

write-host -BackgroundColor Red "No Deployments Assigned"
return 0
}