Monday, September 06, 2021

Windows NTFS Apply New Permissions to SubFolders and Files

 icacls D:\MyPath /grant:r "domain\account":(OI)(CI)M /T


Run this from PowerShell:

cmd.exe /c  "icacls D:\MyPath /grant:r 'domain\account':(OI)(CI)M /T" >> $logpath




Monday, July 05, 2021

Azure list Bastion hosts

az network bastion list

Install Azure CLI for Mac

 1) Install Homebrew

https://brew.sh

2) Before doing a 'brew update' you have to run the following commands:

To `brew update`, first run:

  git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core fetch --unshallow

  git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask fetch --unshallow


3) Install Azure CLI
https://docs.microsoft.com/en-us/cli/azure/install-azure-cli-macos
brew update && brew install azure-cli

4) Login to Azure
az login


Creating an Ansible Control Server for Windows Targets

Creating an Ansible Control Server for Windows Targets

OS: Ubuntu 16.04 Server on Azure

In order for the Control server to use Windows targets, you need Ansible v2.9 or later.

To get Ansible v2.9, install Ansible using pip3 (apt-get installs an older version of Ansible).

To install Python:

sudo apt install sofware-properties-common

sudo add-apt-repository ppa:deadsnakes/ppa


sudo apt update


sudo apt install python3.8


sudo apt install python3-pip


To install Ansible:

pip3 install ansible


Get ansible version:

ansible --version


Install pywinrm (in order to communicate with Windows targets)

pip3 install "pywinrm>=0.3.0"


Ansible Windows Modules:

win_shell

win_command

win_msi

win_copy


Ansible files required on control host at a minumum

e.g. Inside the folder: /home/azureuser/ansible

2 files: 'hosts' and 'ansible.cfg'

ansible.cfg file - specifies where hosts file is.

hosts (not for prod - passwords are cleartext & no cert validation)

[win]

10.2.0.5


[win:vars]

ansible_user=userWithAdminRightsOnTarget

ansible_password=password

ansible_connection=winrm

ansible_winrm_server_cert_validation=ignore


ansible.cfg

[defaults]

inventory=hosts




Example Playbook

---

- hosts: win

  tasks: 

  - name: Copy File

    win_copy: 

      src: C:\temp\1.txt

      dest: c:\temp2\

      remote_src: yes