|
| 1 | +{ |
| 2 | + "cells": [ |
| 3 | + { |
| 4 | + "cell_type": "code", |
| 5 | + "execution_count": 2, |
| 6 | + "metadata": {}, |
| 7 | + "outputs": [ |
| 8 | + { |
| 9 | + "name": "stdout", |
| 10 | + "output_type": "stream", |
| 11 | + "text": [ |
| 12 | + "Creating Directory C:\\Users\\mrrob\\Documents\\dbatoolsdemo\n", |
| 13 | + "Path C:\\Users\\mrrob\\Documents\\dbatoolsdemo exists already\n", |
| 14 | + "Creating Directory C:\\Users\\mrrob\\Documents\\dbatoolsdemo\\SQL1\n", |
| 15 | + "Directory SQL1 exists already\n", |
| 16 | + "Creating File C:\\Users\\mrrob\\Documents\\dbatoolsdemo\\SQL1\\dummyfile.txt\n", |
| 17 | + "Creating Directory C:\\Users\\mrrob\\Documents\\dbatoolsdemo\\SQL2\n", |
| 18 | + "Directory SQL2 exists already\n", |
| 19 | + "Creating File C:\\Users\\mrrob\\Documents\\dbatoolsdemo\\SQL2\\dummyfile.txt\n", |
| 20 | + "Creating a credential file for the containers - Please don't do this in production\n", |
| 21 | + "Credential file created\n", |
| 22 | + "Setting the docker-compose files values\n" |
| 23 | + ] |
| 24 | + } |
| 25 | + ], |
| 26 | + "source": [ |
| 27 | + "$FolderPath = $Env:USERPROFILE + '\\Documents\\dbatoolsdemo'\n", |
| 28 | + "\n", |
| 29 | + "########################################################\n", |
| 30 | + "Write-Output \"Creating Directory $FolderPath\"\n", |
| 31 | + "if(Test-Path $FolderPath){\n", |
| 32 | + " Write-Output \"Path $FolderPath exists already\"\n", |
| 33 | + "}else {\n", |
| 34 | + " $null = New-Item $FolderPath -ItemType Directory\n", |
| 35 | + "}\n", |
| 36 | + "\n", |
| 37 | + "Write-Output \"Creating Directory $FolderPath\\SQL1\"\n", |
| 38 | + "if(Test-Path \"$FolderPath\\SQL1\"){\n", |
| 39 | + " Write-Output \"Directory SQL1 exists already\"\n", |
| 40 | + " Get-ChildItem \"$FolderPath\\SQL1\" -Recurse| Remove-Item -Recurse -Force\n", |
| 41 | + "}else {\n", |
| 42 | + "$null = New-Item \"$FolderPath\\SQL1\"-ItemType Directory\n", |
| 43 | + "}\n", |
| 44 | + "Write-Output \"Creating File $FolderPath\\SQL1\\dummyfile.txt\"\n", |
| 45 | + "if(Test-Path \"$FolderPath\\SQL1\\dummyfile.txt\"){\n", |
| 46 | + " Write-Output \"dummyfile.txt exists already\"\n", |
| 47 | + "}else {\n", |
| 48 | + "$null = New-Item \"$FolderPath\\SQL1\\dummyfile.txt\" -ItemType file\n", |
| 49 | + "}\n", |
| 50 | + "\n", |
| 51 | + "Write-Output \"Creating Directory $FolderPath\\SQL2\"\n", |
| 52 | + "if(Test-Path \"$FolderPath\\SQL2\"){\n", |
| 53 | + " Write-Output \"Directory SQL2 exists already\"\n", |
| 54 | + " Get-ChildItem \"$FolderPath\\SQL2\" -Recurse| Remove-Item -Recurse -Force\n", |
| 55 | + "}else {\n", |
| 56 | + " $null = New-Item \"$FolderPath\\SQL2\"-ItemType Directory\n", |
| 57 | + "}\n", |
| 58 | + "Write-Output \"Creating File $FolderPath\\SQL2\\dummyfile.txt\"\n", |
| 59 | + "if(Test-Path \"$FolderPath\\SQL2\\dummyfile.txt\"){\n", |
| 60 | + " Write-Output \"dummyfile.txt exists already\"\n", |
| 61 | + "}else {\n", |
| 62 | + "$null = New-Item \"$FolderPath\\SQL2\\dummyfile.txt\" -ItemType file\n", |
| 63 | + "}\n", |
| 64 | + "\n", |
| 65 | + "Write-Output \"Creating a credential file for the containers - Please don't do this in production\"\n", |
| 66 | + "\n", |
| 67 | + "$sqladminPassword = ConvertTo-SecureString 'dbatools.IO' -AsPlainText -Force \n", |
| 68 | + "$cred = New-Object System.Management.Automation.PSCredential ('sqladmin', $sqladminpassword)\n", |
| 69 | + "$Cred | Export-Clixml -Path $FolderPath\\sqladmin.cred\n", |
| 70 | + "Write-Output \"Credential file created\"\n", |
| 71 | + "\n", |
| 72 | + "Write-Output \"Setting the docker-compose files values\"\n", |
| 73 | + "$dockercompose = (Get-Content .\\dockercompose.yml) -replace '__ReplaceME__' , $FolderPath\n", |
| 74 | + "# $dockercompose\n", |
| 75 | + "$dockercompose | Set-Content .\\docker-compose.yml" |
| 76 | + ] |
| 77 | + }, |
| 78 | + { |
| 79 | + "cell_type": "code", |
| 80 | + "execution_count": 3, |
| 81 | + "metadata": {}, |
| 82 | + "outputs": [ |
| 83 | + { |
| 84 | + "name": "stdout", |
| 85 | + "output_type": "stream", |
| 86 | + "text": [ |
| 87 | + "Creating network \"agent_BeardsMagicNetwork\" with the default driver\n", |
| 88 | + "Pulling SQL2019 (sqldbawithabeard/dbachecksdemo:)...\n", |
| 89 | + "latest: Pulling from sqldbawithabeard/dbachecksdemo\n", |
| 90 | + "Digest: sha256:6332521d6426eff4a6ed148545d34d28e9f979380400319b54fc98cff48936bd\n", |
| 91 | + "Status: Downloaded newer image for sqldbawithabeard/dbachecksdemo:latest\n", |
| 92 | + "Creating agent_SQL2019_1 ... \n", |
| 93 | + "\n", |
| 94 | + "Creating agent_SQL2019-1_1 ... \n", |
| 95 | + "\n", |
| 96 | + "\u001b[2A\u001b[2K\n", |
| 97 | + "Creating agent_SQL2019_1 ... \u001b[32mdone\u001b[0m\n", |
| 98 | + "\u001b[2B\u001b[1A\u001b[2K\n", |
| 99 | + "Creating agent_SQL2019-1_1 ... \u001b[32mdone\u001b[0m\n", |
| 100 | + "\u001b[1B\n" |
| 101 | + ] |
| 102 | + } |
| 103 | + ], |
| 104 | + "source": [ |
| 105 | + "docker-compose up -d" |
| 106 | + ] |
| 107 | + }, |
| 108 | + { |
| 109 | + "cell_type": "code", |
| 110 | + "execution_count": 9, |
| 111 | + "metadata": {}, |
| 112 | + "outputs": [ |
| 113 | + { |
| 114 | + "name": "stdout", |
| 115 | + "output_type": "stream", |
| 116 | + "text": [ |
| 117 | + "the input device is not a TTY. If you are using mintty, try prefixing the command with 'winpty'\n" |
| 118 | + ] |
| 119 | + } |
| 120 | + ], |
| 121 | + "source": [ |
| 122 | + "docker exec -it agent_SQL2019_1 cat /var/opt/mssql/log/sqlagent.out winpty" |
| 123 | + ] |
| 124 | + }, |
| 125 | + { |
| 126 | + "cell_type": "code", |
| 127 | + "execution_count": null, |
| 128 | + "metadata": {}, |
| 129 | + "outputs": [], |
| 130 | + "source": [] |
| 131 | + } |
| 132 | + ], |
| 133 | + "metadata": { |
| 134 | + "kernelspec": { |
| 135 | + "display_name": ".NET (PowerShell)", |
| 136 | + "language": "PowerShell", |
| 137 | + "name": ".net-powershell" |
| 138 | + }, |
| 139 | + "language_info": { |
| 140 | + "file_extension": ".ps1", |
| 141 | + "mimetype": "text/x-powershell", |
| 142 | + "name": "PowerShell", |
| 143 | + "pygments_lexer": "powershell", |
| 144 | + "version": "7.0" |
| 145 | + } |
| 146 | + }, |
| 147 | + "nbformat": 4, |
| 148 | + "nbformat_minor": 4 |
| 149 | +} |
0 commit comments