Skip to content

Instantly share code, notes, and snippets.

@clong
clong / vmtools.ps1
Last active October 18, 2021 05:25
$software = "VMware Tools";
$installed = (Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* | Where { $_.DisplayName -eq $software }) -ne $null
If ((-Not $installed) -And (Test-Path "C:\Windows\Temp\vmware-vm*")) {
Write-Output "VMware Tools does not appear to be installed. Attempting to install now..."
Write-Output "First, downloading and installing 7z..."
if (!( Test-Path "C:\Windows\Temp\7z2102-x64.msi")) {
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; (New-Object System.Net.WebClient).DownloadFile('https://www.7-zip.org/a/7z2102-x64.msi', 'C:\Windows\Temp\7z2102-x64.msi')
}
if (!(Test-Path "C:\Windows\Temp\7z2102-x64.msi")) {
Start-Sleep 5; [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; (New-Object System.Net.WebClient).DownloadFile('https://www.7-zip.org/a/7z2102-x64.msi', 'C:\Windows\Temp\7z2102-x64.msi')
$ ansible-playbook -v detectionlab.yml --tags "dc"
Using /Users/clong/git-repos/DetectionLab/Azure/Ansible/ansible.cfg as config file
PLAY [dc] *****************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************
TASK [Gathering Facts] ****************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************
ok: [52.183.114.222]
TASK [dc : Set DNS Address] **************************************
PS C:\Users\build\DetectionLab\Vagrant> vagrant destroy -f
==> win10: Running cleanup tasks for 'reload' provisioner...
==> win10: Stopping the VMware VM...
==> win10: Deleting the VM...
==> wef: Running cleanup tasks for 'reload' provisioner...
==> wef: Stopping the VMware VM...
==> wef: Deleting the VM...
Traceback (most recent call last):
103: from C:/HashiCorp/Vagrant/embedded/gems/2.2.13/gems/logging-2.3.0/lib/logging/diagnostic_context.rb:474:in `block in create_with_logging_context'
102: from C:/HashiCorp/Vagrant/embedded/gems/2.2.13/gems/vagrant-2.2.13/lib/vagrant/batch_action.rb:86:in `block (2 levels) in run'
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; iex((iwr -usebasicparsing 'https://gist.githubusercontent.com/clong/7dbda3f8f9d4896914d7ea2ef05ef982/raw/3b545a41f4e3dccb1964e9ed94732828b681cf80/gistfile1.txt').content )
@clong
clong / gist:5eae6a83e6484bb2c01fa5e9cc6e8c9d
Created August 14, 2020 07:15
AWS Policy for DetectionLab Terraform
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"ec2:CreateDhcpOptions",
"ec2:AuthorizeSecurityGroupIngress",
"ec2:DeleteSubnet",
@clong
clong / winrm.ps1
Last active August 3, 2022 20:25
powershell.exe -c "Set-NetConnectionProfile -InterfaceAlias Ethernet -NetworkCategory Private"
powershell.exe -c "Enable-PSRemoting -Force"
winrm quickconfig -q
winrm quickconfig -transport:http
powershell.exe -c "winrm set winrm/config '@{MaxTimeoutms=\`"1800000\`"}'"
powershell.exe -c "winrm set winrm/config/winrs '@{MaxMemoryPerShellMB=\`"800\`"}'"
powershell.exe -c "winrm set winrm/config/service '@{AllowUnencrypted=\`"true\`"}'"
powershell.exe -c "winrm set winrm/config/service/auth '@{Basic=\`"true\`"}'"
powershell.exe -c "winrm set winrm/config/client/auth '@{Basic=\`"true\`"}'"
netsh advfirewall firewall set rule name="Windows Remote Management (HTTP-In)" new enable=yes action=allow remoteip=any
Error retrieving packages from source 'https://chocolatey.org/api/v2/':
Could not connect to the feed specified at 'https://chocolatey.org/api/v2/'.
Please verify that the package source (located in the Package Manager Settings)
is valid and ensure your network connectivity.
# vagrant status --debug
INFO global: Vagrant version: 2.2.4
INFO global: Ruby version: 2.4.4
INFO global: RubyGems version: 2.6.14.1
INFO global: VAGRANT_INSTALLER_EMBEDDED_DIR="/opt/vagrant/embedded"
INFO global: VAGRANT_INSTALLER_ENV="1"
INFO global: VAGRANT_INSTALLER_VERSION="2"
INFO global: VAGRANT_EXECUTABLE="/opt/vagrant/embedded/gems/2.2.4/gems/vagrant-2.2.4/bin/vagrant"
INFO global: VAGRANT_LOG="debug"
WARN global: resolv replacement has not been enabled!
The following WinRM command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!
powershell -ExecutionPolicy Bypass -OutputFormat Text -file "c:\tmp\vagrant-shell.ps1"
Stdout from the command:
Installing Chocolatey
Getting latest version of the Chocolatey package for download.
Getting Chocolatey from https://chocolatey.org/api/v2/package/chocolatey/0.10.13.
$ vagrant reload dc --provision --debug
INFO global: Vagrant version: 2.2.4
INFO global: Ruby version: 2.4.4
INFO global: RubyGems version: 2.6.14.1
INFO global: VAGRANT_DEFAULT_PROVIDER="vmware_desktop"
INFO global: VAGRANT_EXECUTABLE="/opt/vagrant/embedded/gems/2.2.4/gems/vagrant-2.2.4/bin/vagrant"
INFO global: VAGRANT_INSTALLER_VERSION="2"
INFO global: VAGRANT_INSTALLER_ENV="1"
INFO global: VAGRANT_INSTALLER_EMBEDDED_DIR="/opt/vagrant/embedded"
INFO global: VAGRANT_LOG="debug"