Browse Source

Removed all projects except Glazier Agent

Serg Melikyan 6 years ago
parent
commit
0f82f2ec02
100 changed files with 0 additions and 3699 deletions
  1. 0
    0
      .gitignore
  2. 0
    29
      Deployment/ExecutionPlan/1.CreatePrimaryDC/CreatePrimaryDC.json
  3. 0
    9
      Deployment/ExecutionPlan/1.CreatePrimaryDC/ExecutionPlan.txt
  4. 0
    1
      Deployment/ExecutionPlan/1.CreatePrimaryDC/GenerateJSON.bat
  5. 0
    53
      Deployment/ExecutionPlan/1.CreatePrimaryDC/Install-RolePrimaryDomainController.ps1
  6. 0
    9
      Deployment/ExecutionPlan/2.JoinDomain/ExecutionPlan.txt
  7. 0
    1
      Deployment/ExecutionPlan/2.JoinDomain/GenerateJSON.bat
  8. 0
    27
      Deployment/ExecutionPlan/2.JoinDomain/out.json
  9. 0
    8
      Deployment/ExecutionPlan/3.CreateSecondaryDC/ExecutionPlan.txt
  10. 0
    1
      Deployment/ExecutionPlan/3.CreateSecondaryDC/GenerateJSON.bat
  11. 0
    54
      Deployment/ExecutionPlan/3.CreateSecondaryDC/Install-RoleSecondaryDomainController.ps1
  12. 0
    23
      Deployment/ExecutionPlan/3.CreateSecondaryDC/out.json
  13. 0
    10
      Deployment/ExecutionPlan/4.JoinAndPromote/ExecutionPlan.txt
  14. 0
    1
      Deployment/ExecutionPlan/4.JoinAndPromote/GenerateJSON.bat
  15. 0
    54
      Deployment/ExecutionPlan/4.JoinAndPromote/Install-RoleSecondaryDomainController.ps1
  16. 0
    39
      Deployment/ExecutionPlan/4.JoinAndPromote/out.json
  17. BIN
      Deployment/ExecutionPlan/ExecutionPlanGenerator.exe
  18. 0
    7
      Deployment/ExecutionPlan/GetDnsIpAddressesOnDc/ExecutionPlan.txt
  19. 0
    1
      Deployment/ExecutionPlan/GetDnsIpAddressesOnDc/GenerateJSON.bat
  20. 0
    5
      Deployment/ExecutionPlan/GetDnsIpAddressesOnDc/Get-DnsListeningIpAddress.ps1
  21. 0
    12
      Deployment/ExecutionPlan/GetDnsIpAddressesOnDc/out.json
  22. 0
    7
      Deployment/ExecutionPlan/InstallIIS/ExecutionPlan.txt
  23. 0
    1
      Deployment/ExecutionPlan/InstallIIS/GenerateJSON.bat
  24. 0
    4
      Deployment/ExecutionPlan/InstallIIS/Install-WebServer.ps1
  25. 0
    12
      Deployment/ExecutionPlan/InstallIIS/out.json
  26. BIN
      Deployment/ExecutionPlan/Newtonsoft.Json.dll
  27. 0
    44
      Deployment/Unattended/ws-2012-core-unattended.xml
  28. 0
    51
      Deployment/Unattended/ws-2012-full-unattend.xml
  29. 0
    28
      Deployment/WindowsPowerShell/Modules/CoreFunctions/Config.ps1
  30. BIN
      Deployment/WindowsPowerShell/Modules/CoreFunctions/CoreFunctions.psd1
  31. 0
    36
      Deployment/WindowsPowerShell/Modules/CoreFunctions/CoreFunctions.psm1
  32. BIN
      Deployment/WindowsPowerShell/Modules/CoreFunctions/Ionic.Zip.dll
  33. 0
    0
      Deployment/WindowsPowerShell/Modules/CoreFunctions/en-US/about_CoreFunctions.help.txt
  34. 0
    99
      Deployment/WindowsPowerShell/Modules/CoreFunctions/include/Base64.ps1
  35. 0
    388
      Deployment/WindowsPowerShell/Modules/CoreFunctions/include/Functions.ps1
  36. 0
    137
      Deployment/WindowsPowerShell/Modules/CoreFunctions/include/Logger.ps1
  37. 0
    0
      Deployment/WindowsPowerShell/Modules/CoreFunctions/include/Module.ps1
  38. 0
    814
      Deployment/WindowsPowerShell/Modules/CoreFunctions/include/NotCoreFunctions.ps1
  39. 0
    1
      Deployment/WindowsPowerShell/Modules/CoreFunctions/include/SqlFunctions.ps1
  40. 0
    69
      Deployment/WindowsPowerShell/Modules/CoreFunctions/include/Zip.ps1
  41. 0
    42
      Deployment/WindowsPowerShell/Modules/CoreFunctions/log4net.config
  42. BIN
      Deployment/WindowsPowerShell/Modules/CoreFunctions/log4net.dll
  43. 0
    11
      Deployment/cloudbase-init/config/cloudbase-init.conf
  44. 0
    37
      Deployment/cloudbase-init/plugins/setagentconfig.py
  45. 0
    20
      Deployment/cloudbase-init/plugins/sethostname.py
  46. 0
    119
      Deployment/cloudbase-init/plugins/userdata.py
  47. 0
    24
      Deployment/cloudbase-init/userdata/Sample.ps1
  48. 0
    51
      Deployment/devstack-scripts/compute/devstack.localrc
  49. 0
    45
      Deployment/devstack-scripts/controller/devstack.localrc
  50. 0
    28
      Deployment/devstack-scripts/devstack.standalone.localrc
  51. 0
    148
      Deployment/devstack-scripts/functions.sh
  52. 0
    21
      Deployment/devstack-scripts/install-devstack.sh
  53. 0
    20
      Deployment/devstack-scripts/localrc
  54. 0
    109
      Deployment/devstack-scripts/post-stack.sh
  55. 0
    36
      Deployment/devstack-scripts/post-unstack.sh
  56. 0
    55
      Deployment/devstack-scripts/pre-stack.sh
  57. 0
    7
      Deployment/devstack-scripts/pre-unstack.sh
  58. 0
    53
      Deployment/devstack-scripts/ss1285.interfaces.example
  59. 0
    54
      Deployment/devstack-scripts/ss1383.interfaces.example
  60. 0
    27
      Deployment/devstack-scripts/standalone/devstack.localrc
  61. 0
    63
      Deployment/devstack-scripts/start-devstack.sh
  62. 0
    26
      Deployment/devstack-scripts/start-keero.sh
  63. 0
    22
      Deployment/devstack-scripts/start-vm.sh
  64. 0
    45
      Deployment/devstack-scripts/stop-devstack.sh
  65. 0
    13
      Deployment/devstack-scripts/stop-keero.sh
  66. 0
    0
      ExecutionPlanGenerator/App.config
  67. 0
    0
      ExecutionPlanGenerator/ExecutionPlanGenerator.csproj
  68. 0
    0
      ExecutionPlanGenerator/Program.cs
  69. 0
    0
      ExecutionPlanGenerator/Properties/AssemblyInfo.cs
  70. 0
    0
      ExecutionPlanGenerator/packages.config
  71. 0
    0
      Tools/NuGet.exe
  72. 0
    0
      WindowsAgent.sln
  73. 0
    0
      WindowsAgent/App.config
  74. 0
    0
      WindowsAgent/ExecutionPlan.cs
  75. 0
    0
      WindowsAgent/MqMessage.cs
  76. 0
    0
      WindowsAgent/PlanExecutor.cs
  77. 0
    0
      WindowsAgent/Program.cs
  78. 0
    0
      WindowsAgent/Properties/AssemblyInfo.cs
  79. 0
    0
      WindowsAgent/RabbitMqClient.cs
  80. 0
    0
      WindowsAgent/SampleExecutionPlan.json
  81. 0
    0
      WindowsAgent/ServiceManager.cs
  82. 0
    0
      WindowsAgent/WindowsAgent.csproj
  83. 0
    0
      WindowsAgent/WindowsService.cs
  84. 0
    0
      WindowsAgent/WindowsServiceInstaller.cs
  85. 0
    0
      WindowsAgent/packages.config
  86. 0
    23
      api/.gitignore
  87. 0
    7
      api/README.rst
  88. 0
    1
      api/babel.cfg
  89. 0
    54
      api/bin/glazier-api
  90. 0
    0
      api/doc/source/_static/.placeholder
  91. 0
    0
      api/doc/source/_templates/.placeholder
  92. 0
    2
      api/doc/source/_theme/theme.conf
  93. 0
    241
      api/doc/source/conf.py
  94. 0
    114
      api/doc/source/index.rst
  95. 0
    69
      api/doc/source/man/glazierapi.rst
  96. 0
    18
      api/etc/glazier-api-paste.ini
  97. 0
    32
      api/etc/glazier-api.conf
  98. 0
    13
      api/glazierapi/__init__.py
  99. 0
    14
      api/glazierapi/api/__init__.py
  100. 0
    0
      api/glazierapi/api/middleware/__init__.py

WindowsAgent/.gitignore → .gitignore View File


+ 0
- 29
Deployment/ExecutionPlan/1.CreatePrimaryDC/CreatePrimaryDC.json View File

@@ -1,29 +0,0 @@
1
-{
2
-  "Scripts": [
3
-    "DQpGdW5jdGlvbiBJbnN0YWxsLVJvbGVQcmltYXJ5RG9tYWluQ29udHJvbGxlcg0Kew0KPCMNCi5TWU5PUFNJUw0KQ29uZmlndXJlIG5vZGUncyBuZXR3b3JrIGFkYXB0ZXJzLg0KQ3JlYXRlIGZpcnN0IGRvbWFpbiBjb250cm9sbGVyIGluIHRoZSBmb3Jlc3QuDQoNCi5FWEFNUExFDQpQUz4gSW5zdGFsbC1Sb2xlUHJpbWFyeURvbWFpbkNvbnRyb2xsZXIgLURvbWFpbk5hbWUgYWNtZS5sb2NhbCAtU2FmZU1vZGVQYXNzd29yZCAiUEBzc3cwcmQiDQoNCkluc3RhbGwgRE5TIGFuZCBBRERTLCBjcmVhdGUgZm9yZXN0IGFuZCBkb21haW4gJ2FjbWUubG9jYWwnLg0KU2V0IERDIHJlY292ZXJ5IG1vZGUgcGFzc3dvcmQgdG8gJ1BAc3N3MHJkJy4NCiM+DQoJDQoJcGFyYW0NCgkoDQoJCVtTdHJpbmddDQoJCSMgTmV3IGRvbWFpbiBuYW1lLg0KCQkkRG9tYWluTmFtZSwNCgkJDQoJCVtTdHJpbmddDQoJCSMgRG9tYWluIGNvbnRyb2xsZXIgcmVjb3ZlcnkgbW9kZSBwYXNzd29yZC4NCgkJJFNhZmVNb2RlUGFzc3dvcmQNCgkpDQoNCgl0cmFwIHsgU3RvcC1FeGVjdXRpb24gJF8gfQ0KDQogICAgICAgICMgQWRkIHJlcXVpcmVkIHdpbmRvd3MgZmVhdHVyZXMNCglBZGQtV2luZG93c0ZlYXR1cmVXcmFwcGVyIGANCgkJLU5hbWUgIkROUyIsIkFELURvbWFpbi1TZXJ2aWNlcyIsIlJTQVQtREZTLU1nbXQtQ29uIiBgDQoJCS1JbmNsdWRlTWFuYWdlbWVudFRvb2xzIGANCiAgICAgICAgLU5vdGlmeVJlc3RhcnQNCg0KDQoJV3JpdGUtTG9nICJDcmVhdGluZyBmaXJzdCBkb21haW4gY29udHJvbGxlciAuLi4iDQoJCQ0KCSRTTUFQID0gQ29udmVydFRvLVNlY3VyZVN0cmluZyAtU3RyaW5nICRTYWZlTW9kZVBhc3N3b3JkIC1Bc1BsYWluVGV4dCAtRm9yY2UNCgkJDQoJSW5zdGFsbC1BRERTRm9yZXN0IGANCgkJLURvbWFpbk5hbWUgJERvbWFpbk5hbWUgYA0KCQktU2FmZU1vZGVBZG1pbmlzdHJhdG9yUGFzc3dvcmQgJFNNQVAgYA0KCQktRG9tYWluTW9kZSBEZWZhdWx0IGANCgkJLUZvcmVzdE1vZGUgRGVmYXVsdCBgDQoJCS1Ob1JlYm9vdE9uQ29tcGxldGlvbiBgDQoJCS1Gb3JjZSBgDQoJCS1FcnJvckFjdGlvbiBTdG9wIHwgT3V0LU51bGwNCg0KCVdyaXRlLUxvZyAiV2FpdGluZyBmb3IgcmVib290IC4uLiIJCQ0KIwlTdG9wLUV4ZWN1dGlvbiAtRXhpdENvZGUgMzAxMCAtRXhpdFN0cmluZyAiQ29tcHV0ZXIgbXVzdCBiZSByZXN0YXJ0ZWQgdG8gZmluaXNoIGRvbWFpbiBjb250cm9sbGVyIHByb21vdGlvbi4iDQojCVdyaXRlLUxvZyAiUmVzdGFyaW5nIGNvbXB1dGVyIC4uLiINCiMJUmVzdGFydC1Db21wdXRlciAtRm9yY2UNCn0NCg=="
4
-  ],
5
-  "Commands": [
6
-    {
7
-      "Name": "Import-Module",
8
-      "Arguments": {
9
-        "Name": "CoreFunctions"
10
-      }
11
-    },
12
-    {
13
-      "Name": "Set-LocalUserPassword",
14
-      "Arguments": {
15
-        "UserName": "Administrator",
16
-        "Password": "P@ssw0rd123",
17
-        "Force": true
18
-      }
19
-    },
20
-    {
21
-      "Name": "Install-RolePrimaryDomainController",
22
-      "Arguments": {
23
-        "DomainName": "acme.local",
24
-        "SafeModePassword": "P@ssw0rd"
25
-      }
26
-    }
27
-  ],
28
-  "RebootOnCompletion": 1
29
-}

+ 0
- 9
Deployment/ExecutionPlan/1.CreatePrimaryDC/ExecutionPlan.txt View File

@@ -1,9 +0,0 @@
1
-include Install-RolePrimaryDomainController.ps1
2
-
3
-call Import-Module Name="CoreFunctions"
4
-call Set-LocalUserPassword UserName="Administrator" , Password="P@ssw0rd123" , Force=true
5
-call Install-RolePrimaryDomainController DomainName="acme.local" , SafeModePassword="P@ssw0rd"
6
-
7
-reboot 1
8
-
9
-out CreatePrimaryDC.json

+ 0
- 1
Deployment/ExecutionPlan/1.CreatePrimaryDC/GenerateJSON.bat View File

@@ -1 +0,0 @@
1
-..\ExecutionPlanGenerator.exe ExecutionPlan.txt

+ 0
- 53
Deployment/ExecutionPlan/1.CreatePrimaryDC/Install-RolePrimaryDomainController.ps1 View File

@@ -1,53 +0,0 @@
1
-
2
-Function Install-RolePrimaryDomainController
3
-{
4
-<#
5
-.SYNOPSIS
6
-Configure node's network adapters.
7
-Create first domain controller in the forest.
8
-
9
-.EXAMPLE
10
-PS> Install-RolePrimaryDomainController -DomainName acme.local -SafeModePassword "P@ssw0rd"
11
-
12
-Install DNS and ADDS, create forest and domain 'acme.local'.
13
-Set DC recovery mode password to 'P@ssw0rd'.
14
-#>
15
-	
16
-	param
17
-	(
18
-		[String]
19
-		# New domain name.
20
-		$DomainName,
21
-		
22
-		[String]
23
-		# Domain controller recovery mode password.
24
-		$SafeModePassword
25
-	)
26
-
27
-	trap { Stop-Execution $_ }
28
-
29
-        # Add required windows features
30
-	Add-WindowsFeatureWrapper `
31
-		-Name "DNS","AD-Domain-Services","RSAT-DFS-Mgmt-Con" `
32
-		-IncludeManagementTools `
33
-        -NotifyRestart
34
-
35
-
36
-	Write-Log "Creating first domain controller ..."
37
-		
38
-	$SMAP = ConvertTo-SecureString -String $SafeModePassword -AsPlainText -Force
39
-		
40
-	Install-ADDSForest `
41
-		-DomainName $DomainName `
42
-		-SafeModeAdministratorPassword $SMAP `
43
-		-DomainMode Default `
44
-		-ForestMode Default `
45
-		-NoRebootOnCompletion `
46
-		-Force `
47
-		-ErrorAction Stop | Out-Null
48
-
49
-	Write-Log "Waiting for reboot ..."		
50
-#	Stop-Execution -ExitCode 3010 -ExitString "Computer must be restarted to finish domain controller promotion."
51
-#	Write-Log "Restaring computer ..."
52
-#	Restart-Computer -Force
53
-}

+ 0
- 9
Deployment/ExecutionPlan/2.JoinDomain/ExecutionPlan.txt View File

@@ -1,9 +0,0 @@
1
-call Import-Module Name="CoreFunctions"
2
-call Set-NetworkAdapterConfiguration FirstAvailable=true , DNSServer="10.0.102.2"
3
-call Join-Domain DomainName="acme.local" , Username="Administrator" , Password="P@ssw0rd123"
4
-
5
-reboot 1
6
-
7
-out out.json
8
-
9
-

+ 0
- 1
Deployment/ExecutionPlan/2.JoinDomain/GenerateJSON.bat View File

@@ -1 +0,0 @@
1
-..\ExecutionPlanGenerator.exe ExecutionPlan.txt

+ 0
- 27
Deployment/ExecutionPlan/2.JoinDomain/out.json View File

@@ -1,27 +0,0 @@
1
-{
2
-  "Scripts": [],
3
-  "Commands": [
4
-    {
5
-      "Name": "Import-Module",
6
-      "Arguments": {
7
-        "Name": "CoreFunctions"
8
-      }
9
-    },
10
-    {
11
-      "Name": "Set-NetworkAdapterConfiguration",
12
-      "Arguments": {
13
-        "FirstAvailable": true,
14
-        "DNSServer": "10.0.102.2"
15
-      }
16
-    },
17
-    {
18
-      "Name": "Join-Domain",
19
-      "Arguments": {
20
-        "DomainName": "acme.local",
21
-        "Username": "Administrator",
22
-        "Password": "P@ssw0rd123"
23
-      }
24
-    }
25
-  ],
26
-  "RebootOnCompletion": 1
27
-}

+ 0
- 8
Deployment/ExecutionPlan/3.CreateSecondaryDC/ExecutionPlan.txt View File

@@ -1,8 +0,0 @@
1
-include Install-RoleSecondaryDomainController.ps1
2
-
3
-call Import-Module Name="CoreFunctions"
4
-call Install-RoleSecondaryDomainController DomainName="acme.local" , UserName="Administrator" , Password="P@ssw0rd123" , SafeModePassword="P@ssw0rd"
5
-
6
-reboot 1
7
-
8
-out out.json

+ 0
- 1
Deployment/ExecutionPlan/3.CreateSecondaryDC/GenerateJSON.bat View File

@@ -1 +0,0 @@
1
-..\ExecutionPlanGenerator.exe ExecutionPlan.txt

+ 0
- 54
Deployment/ExecutionPlan/3.CreateSecondaryDC/Install-RoleSecondaryDomainController.ps1 View File

@@ -1,54 +0,0 @@
1
-Function Install-RoleSecondaryDomainController
2
-{
3
-<#
4
-.SYNOPSIS
5
-Install additional (secondary) domain controller.
6
-
7
-#>
8
-	param
9
-	(
10
-		[String]
11
-		# Domain name to join to.
12
-		$DomainName,
13
-		
14
-		[String]
15
-		# Domain user who is allowed to join computer to domain.
16
-		$UserName,
17
-		
18
-		[String]
19
-		# User's password.
20
-		$Password,
21
-		
22
-		[String]
23
-		# Domain controller recovery mode password.
24
-		$SafeModePassword
25
-	)
26
-
27
-	trap { Stop-Execution $_ }
28
-	
29
-	$Credential = New-Credential -UserName "$DomainName\$UserName" -Password $Password
30
-		
31
-	# Add required windows features
32
-	Add-WindowsFeatureWrapper `
33
-		-Name "DNS","AD-Domain-Services","RSAT-DFS-Mgmt-Con" `
34
-		-IncludeManagementTools `
35
-                -NotifyRestart
36
-		
37
-	
38
-        Write-Log "Adding secondary domain controller ..."
39
-    
40
-	$SMAP = ConvertTo-SecureString -String $SafeModePassword -AsPlainText -Force
41
-
42
-	Install-ADDSDomainController `
43
-		-DomainName $DomainName `
44
-		-SafeModeAdministratorPassword $SMAP `
45
-		-Credential $Credential `
46
-		-NoRebootOnCompletion `
47
-		-Force `
48
-		-ErrorAction Stop | Out-Null
49
-
50
-	Write-Log "Waiting for restart ..."
51
-#	Stop-Execution -ExitCode 3010 -ExitString "Computer must be restarted to finish domain controller promotion."
52
-#	Write-Log "Restarting computer ..."
53
-#	Restart-Computer -Force
54
-}

+ 0
- 23
Deployment/ExecutionPlan/3.CreateSecondaryDC/out.json View File

@@ -1,23 +0,0 @@
1
-{
2
-  "Scripts": [
3
-    "RnVuY3Rpb24gSW5zdGFsbC1Sb2xlU2Vjb25kYXJ5RG9tYWluQ29udHJvbGxlcg0Kew0KPCMNCi5TWU5PUFNJUw0KSW5zdGFsbCBhZGRpdGlvbmFsIChzZWNvbmRhcnkpIGRvbWFpbiBjb250cm9sbGVyLg0KDQojPg0KCXBhcmFtDQoJKA0KCQlbU3RyaW5nXQ0KCQkjIERvbWFpbiBuYW1lIHRvIGpvaW4gdG8uDQoJCSREb21haW5OYW1lLA0KCQkNCgkJW1N0cmluZ10NCgkJIyBEb21haW4gdXNlciB3aG8gaXMgYWxsb3dlZCB0byBqb2luIGNvbXB1dGVyIHRvIGRvbWFpbi4NCgkJJFVzZXJOYW1lLA0KCQkNCgkJW1N0cmluZ10NCgkJIyBVc2VyJ3MgcGFzc3dvcmQuDQoJCSRQYXNzd29yZCwNCgkJDQoJCVtTdHJpbmddDQoJCSMgRG9tYWluIGNvbnRyb2xsZXIgcmVjb3ZlcnkgbW9kZSBwYXNzd29yZC4NCgkJJFNhZmVNb2RlUGFzc3dvcmQNCgkpDQoNCgl0cmFwIHsgU3RvcC1FeGVjdXRpb24gJF8gfQ0KCQ0KCSRDcmVkZW50aWFsID0gTmV3LUNyZWRlbnRpYWwgLVVzZXJOYW1lICIkRG9tYWluTmFtZVwkVXNlck5hbWUiIC1QYXNzd29yZCAkUGFzc3dvcmQNCgkJDQoJIyBBZGQgcmVxdWlyZWQgd2luZG93cyBmZWF0dXJlcw0KCUFkZC1XaW5kb3dzRmVhdHVyZVdyYXBwZXIgYA0KCQktTmFtZSAiRE5TIiwiQUQtRG9tYWluLVNlcnZpY2VzIiwiUlNBVC1ERlMtTWdtdC1Db24iIGANCgkJLUluY2x1ZGVNYW5hZ2VtZW50VG9vbHMgYA0KICAgICAgICAgICAgICAgIC1Ob3RpZnlSZXN0YXJ0DQoJCQ0KCQ0KICAgICAgICBXcml0ZS1Mb2cgIkFkZGluZyBzZWNvbmRhcnkgZG9tYWluIGNvbnRyb2xsZXIgLi4uIg0KICAgIA0KCSRTTUFQID0gQ29udmVydFRvLVNlY3VyZVN0cmluZyAtU3RyaW5nICRTYWZlTW9kZVBhc3N3b3JkIC1Bc1BsYWluVGV4dCAtRm9yY2UNCg0KCUluc3RhbGwtQUREU0RvbWFpbkNvbnRyb2xsZXIgYA0KCQktRG9tYWluTmFtZSAkRG9tYWluTmFtZSBgDQoJCS1TYWZlTW9kZUFkbWluaXN0cmF0b3JQYXNzd29yZCAkU01BUCBgDQoJCS1DcmVkZW50aWFsICRDcmVkZW50aWFsIGANCgkJLU5vUmVib290T25Db21wbGV0aW9uIGANCgkJLUZvcmNlIGANCgkJLUVycm9yQWN0aW9uIFN0b3AgfCBPdXQtTnVsbA0KDQoJV3JpdGUtTG9nICJXYWl0aW5nIGZvciByZXN0YXJ0IC4uLiINCiMJU3RvcC1FeGVjdXRpb24gLUV4aXRDb2RlIDMwMTAgLUV4aXRTdHJpbmcgIkNvbXB1dGVyIG11c3QgYmUgcmVzdGFydGVkIHRvIGZpbmlzaCBkb21haW4gY29udHJvbGxlciBwcm9tb3Rpb24uIg0KIwlXcml0ZS1Mb2cgIlJlc3RhcnRpbmcgY29tcHV0ZXIgLi4uIg0KIwlSZXN0YXJ0LUNvbXB1dGVyIC1Gb3JjZQ0KfQ0K"
4
-  ],
5
-  "Commands": [
6
-    {
7
-      "Name": "Import-Module",
8
-      "Arguments": {
9
-        "Name": "CoreFunctions"
10
-      }
11
-    },
12
-    {
13
-      "Name": "Install-RoleSecondaryDomainController",
14
-      "Arguments": {
15
-        "DomainName": "acme.local",
16
-        "UserName": "Administrator",
17
-        "Password": "P@ssw0rd123",
18
-        "SafeModePassword": "P@ssw0rd"
19
-      }
20
-    }
21
-  ],
22
-  "RebootOnCompletion": 1
23
-}

+ 0
- 10
Deployment/ExecutionPlan/4.JoinAndPromote/ExecutionPlan.txt View File

@@ -1,10 +0,0 @@
1
-include Install-RoleSecondaryDomainController.ps1
2
-
3
-call Import-Module Name="CoreFunctions"
4
-call Set-NetworkAdapterConfiguration FirstAvailable=true , DNSServer="10.0.102.2"
5
-call Join-Domain DomainName="acme.local" , Username="Administrator" , Password="P@ssw0rd123" , AllowRestart=true
6
-call Install-RoleSecondaryDomainController DomainName="acme.local" , UserName="Administrator" , Password="P@ssw0rd123" , SafeModePassword="P@ssw0rd"
7
-
8
-reboot 1
9
-
10
-out out.json

+ 0
- 1
Deployment/ExecutionPlan/4.JoinAndPromote/GenerateJSON.bat View File

@@ -1 +0,0 @@
1
-..\ExecutionPlanGenerator.exe ExecutionPlan.txt

+ 0
- 54
Deployment/ExecutionPlan/4.JoinAndPromote/Install-RoleSecondaryDomainController.ps1 View File

@@ -1,54 +0,0 @@
1
-Function Install-RoleSecondaryDomainController
2
-{
3
-<#
4
-.SYNOPSIS
5
-Install additional (secondary) domain controller.
6
-
7
-#>
8
-	param
9
-	(
10
-		[String]
11
-		# Domain name to join to.
12
-		$DomainName,
13
-		
14
-		[String]
15
-		# Domain user who is allowed to join computer to domain.
16
-		$UserName,
17
-		
18
-		[String]
19
-		# User's password.
20
-		$Password,
21
-		
22
-		[String]
23
-		# Domain controller recovery mode password.
24
-		$SafeModePassword
25
-	)
26
-
27
-	trap { Stop-Execution $_ }
28
-	
29
-	$Credential = New-Credential -UserName "$DomainName\$UserName" -Password $Password
30
-		
31
-	# Add required windows features
32
-	Add-WindowsFeatureWrapper `
33
-		-Name "DNS","AD-Domain-Services","RSAT-DFS-Mgmt-Con" `
34
-		-IncludeManagementTools `
35
-                -NotifyRestart
36
-		
37
-	
38
-        Write-Log "Adding secondary domain controller ..."
39
-    
40
-	$SMAP = ConvertTo-SecureString -String $SafeModePassword -AsPlainText -Force
41
-
42
-	Install-ADDSDomainController `
43
-		-DomainName $DomainName `
44
-		-SafeModeAdministratorPassword $SMAP `
45
-		-Credential $Credential `
46
-		-NoRebootOnCompletion `
47
-		-Force `
48
-		-ErrorAction Stop | Out-Null
49
-
50
-	Write-Log "Waiting for restart ..."
51
-#	Stop-Execution -ExitCode 3010 -ExitString "Computer must be restarted to finish domain controller promotion."
52
-#	Write-Log "Restarting computer ..."
53
-#	Restart-Computer -Force
54
-}

+ 0
- 39
Deployment/ExecutionPlan/4.JoinAndPromote/out.json View File

@@ -1,39 +0,0 @@
1
-{
2
-  "Scripts": [
3
-    "RnVuY3Rpb24gSW5zdGFsbC1Sb2xlU2Vjb25kYXJ5RG9tYWluQ29udHJvbGxlcg0Kew0KPCMNCi5TWU5PUFNJUw0KSW5zdGFsbCBhZGRpdGlvbmFsIChzZWNvbmRhcnkpIGRvbWFpbiBjb250cm9sbGVyLg0KDQojPg0KCXBhcmFtDQoJKA0KCQlbU3RyaW5nXQ0KCQkjIERvbWFpbiBuYW1lIHRvIGpvaW4gdG8uDQoJCSREb21haW5OYW1lLA0KCQkNCgkJW1N0cmluZ10NCgkJIyBEb21haW4gdXNlciB3aG8gaXMgYWxsb3dlZCB0byBqb2luIGNvbXB1dGVyIHRvIGRvbWFpbi4NCgkJJFVzZXJOYW1lLA0KCQkNCgkJW1N0cmluZ10NCgkJIyBVc2VyJ3MgcGFzc3dvcmQuDQoJCSRQYXNzd29yZCwNCgkJDQoJCVtTdHJpbmddDQoJCSMgRG9tYWluIGNvbnRyb2xsZXIgcmVjb3ZlcnkgbW9kZSBwYXNzd29yZC4NCgkJJFNhZmVNb2RlUGFzc3dvcmQNCgkpDQoNCgl0cmFwIHsgU3RvcC1FeGVjdXRpb24gJF8gfQ0KCQ0KCSRDcmVkZW50aWFsID0gTmV3LUNyZWRlbnRpYWwgLVVzZXJOYW1lICIkRG9tYWluTmFtZVwkVXNlck5hbWUiIC1QYXNzd29yZCAkUGFzc3dvcmQNCgkJDQoJIyBBZGQgcmVxdWlyZWQgd2luZG93cyBmZWF0dXJlcw0KCUFkZC1XaW5kb3dzRmVhdHVyZVdyYXBwZXIgYA0KCQktTmFtZSAiRE5TIiwiQUQtRG9tYWluLVNlcnZpY2VzIiwiUlNBVC1ERlMtTWdtdC1Db24iIGANCgkJLUluY2x1ZGVNYW5hZ2VtZW50VG9vbHMgYA0KICAgICAgICAgICAgICAgIC1Ob3RpZnlSZXN0YXJ0DQoJCQ0KCQ0KICAgICAgICBXcml0ZS1Mb2cgIkFkZGluZyBzZWNvbmRhcnkgZG9tYWluIGNvbnRyb2xsZXIgLi4uIg0KICAgIA0KCSRTTUFQID0gQ29udmVydFRvLVNlY3VyZVN0cmluZyAtU3RyaW5nICRTYWZlTW9kZVBhc3N3b3JkIC1Bc1BsYWluVGV4dCAtRm9yY2UNCg0KCUluc3RhbGwtQUREU0RvbWFpbkNvbnRyb2xsZXIgYA0KCQktRG9tYWluTmFtZSAkRG9tYWluTmFtZSBgDQoJCS1TYWZlTW9kZUFkbWluaXN0cmF0b3JQYXNzd29yZCAkU01BUCBgDQoJCS1DcmVkZW50aWFsICRDcmVkZW50aWFsIGANCgkJLU5vUmVib290T25Db21wbGV0aW9uIGANCgkJLUZvcmNlIGANCgkJLUVycm9yQWN0aW9uIFN0b3AgfCBPdXQtTnVsbA0KDQoJV3JpdGUtTG9nICJXYWl0aW5nIGZvciByZXN0YXJ0IC4uLiINCiMJU3RvcC1FeGVjdXRpb24gLUV4aXRDb2RlIDMwMTAgLUV4aXRTdHJpbmcgIkNvbXB1dGVyIG11c3QgYmUgcmVzdGFydGVkIHRvIGZpbmlzaCBkb21haW4gY29udHJvbGxlciBwcm9tb3Rpb24uIg0KIwlXcml0ZS1Mb2cgIlJlc3RhcnRpbmcgY29tcHV0ZXIgLi4uIg0KIwlSZXN0YXJ0LUNvbXB1dGVyIC1Gb3JjZQ0KfQ0K"
4
-  ],
5
-  "Commands": [
6
-    {
7
-      "Name": "Import-Module",
8
-      "Arguments": {
9
-        "Name": "CoreFunctions"
10
-      }
11
-    },
12
-    {
13
-      "Name": "Set-NetworkAdapterConfiguration",
14
-      "Arguments": {
15
-        "FirstAvailable": true,
16
-        "DNSServer": "10.0.102.2"
17
-      }
18
-    },
19
-    {
20
-      "Name": "Join-Domain",
21
-      "Arguments": {
22
-        "DomainName": "acme.local",
23
-        "Username": "Administrator",
24
-        "Password": "P@ssw0rd123",
25
-        "AllowRestart": true
26
-      }
27
-    },
28
-    {
29
-      "Name": "Install-RoleSecondaryDomainController",
30
-      "Arguments": {
31
-        "DomainName": "acme.local",
32
-        "UserName": "Administrator",
33
-        "Password": "P@ssw0rd123",
34
-        "SafeModePassword": "P@ssw0rd"
35
-      }
36
-    }
37
-  ],
38
-  "RebootOnCompletion": 1
39
-}

BIN
Deployment/ExecutionPlan/ExecutionPlanGenerator.exe View File


+ 0
- 7
Deployment/ExecutionPlan/GetDnsIpAddressesOnDc/ExecutionPlan.txt View File

@@ -1,7 +0,0 @@
1
-include Get-DnsListeningIpAddress.ps1
2
-
3
-call Get-DnsListeningIpAddress
4
-
5
-reboot 0
6
-
7
-out out.json

+ 0
- 1
Deployment/ExecutionPlan/GetDnsIpAddressesOnDc/GenerateJSON.bat View File

@@ -1 +0,0 @@
1
-..\ExecutionPlanGenerator.exe ExecutionPlan.txt

+ 0
- 5
Deployment/ExecutionPlan/GetDnsIpAddressesOnDc/Get-DnsListeningIpAddress.ps1 View File

@@ -1,5 +0,0 @@
1
-function Get-DnsListeningIpAddress {
2
-    Import-Module DnsServer
3
-    (Get-DNSServer -ComputerName localhost).ServerSetting.ListeningIpAddress |
4
-        Where-Object { $_ -match "\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}" }
5
-}

+ 0
- 12
Deployment/ExecutionPlan/GetDnsIpAddressesOnDc/out.json View File

@@ -1,12 +0,0 @@
1
-{
2
-  "Scripts": [
3
-    "ZnVuY3Rpb24gR2V0LURuc0xpc3RlbmluZ0lwQWRkcmVzcyB7DQogICAgSW1wb3J0LU1vZHVsZSBEbnNTZXJ2ZXINCiAgICAoR2V0LUROU1NlcnZlciAtQ29tcHV0ZXJOYW1lIGxvY2FsaG9zdCkuU2VydmVyU2V0dGluZy5MaXN0ZW5pbmdJcEFkZHJlc3MgfA0KICAgICAgICBXaGVyZS1PYmplY3QgeyAkXyAtbWF0Y2ggIlxkezEsM31cLlxkezEsM31cLlxkezEsM31cLlxkezEsM30iIH0NCn0NCg=="
4
-  ],
5
-  "Commands": [
6
-    {
7
-      "Name": "Get-DnsListeningIpAddress",
8
-      "Arguments": {}
9
-    }
10
-  ],
11
-  "RebootOnCompletion": 0
12
-}

+ 0
- 7
Deployment/ExecutionPlan/InstallIIS/ExecutionPlan.txt View File

@@ -1,7 +0,0 @@
1
-include Install-WebServer.ps1
2
-
3
-call Install-WebServer
4
-
5
-reboot 0
6
-
7
-out out.json

+ 0
- 1
Deployment/ExecutionPlan/InstallIIS/GenerateJSON.bat View File

@@ -1 +0,0 @@
1
-..\ExecutionPlanGenerator.exe ExecutionPlan.txt

+ 0
- 4
Deployment/ExecutionPlan/InstallIIS/Install-WebServer.ps1 View File

@@ -1,4 +0,0 @@
1
-function Install-WebServer {
2
-    Import-Module ServerManager
3
-    Install-WindowsFeature Web-Server -IncludeManagementTools
4
-}

+ 0
- 12
Deployment/ExecutionPlan/InstallIIS/out.json View File

@@ -1,12 +0,0 @@
1
-{
2
-  "Scripts": [
3
-    "ZnVuY3Rpb24gSW5zdGFsbC1XZWJTZXJ2ZXIgew0KICAgIEltcG9ydC1Nb2R1bGUgU2VydmVyTWFuYWdlcg0KICAgIEluc3RhbGwtV2luZG93c0ZlYXR1cmUgV2ViLVNlcnZlciAtSW5jbHVkZU1hbmFnZW1lbnRUb29scw0KfQ0K"
4
-  ],
5
-  "Commands": [
6
-    {
7
-      "Name": "Install-WebServer",
8
-      "Arguments": {}
9
-    }
10
-  ],
11
-  "RebootOnCompletion": 0
12
-}

BIN
Deployment/ExecutionPlan/Newtonsoft.Json.dll View File


+ 0
- 44
Deployment/Unattended/ws-2012-core-unattended.xml View File

@@ -1,44 +0,0 @@
1
-<?xml version="1.0" encoding="utf-8"?>
2
-<unattend xmlns="urn:schemas-microsoft-com:unattend">
3
-    <settings pass="specialize">
4
-        <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
5
-            <TimeZone>Pacific Standard Time</TimeZone>
6
-        </component>
7
-    </settings>
8
-    <settings pass="oobeSystem">
9
-        <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
10
-            <AutoLogon>
11
-                <Password>
12
-                    <Value>UABAAHMAcwB3ADAAcgBkAFAAYQBzAHMAdwBvAHIAZAA=</Value>
13
-                    <PlainText>false</PlainText>
14
-                </Password>
15
-                <Username>Administrator</Username>
16
-                <LogonCount>1</LogonCount>
17
-                <Enabled>false</Enabled>
18
-            </AutoLogon>
19
-            <UserAccounts>
20
-                <AdministratorPassword>
21
-                    <Value>UABAAHMAcwB3ADAAcgBkAEEAZABtAGkAbgBpAHMAdAByAGEAdABvAHIAUABhAHMAcwB3AG8AcgBkAA==</Value>
22
-                    <PlainText>false</PlainText>
23
-                </AdministratorPassword>
24
-            </UserAccounts>
25
-            <RegisteredOrganization>-</RegisteredOrganization>
26
-            <RegisteredOwner>-</RegisteredOwner>
27
-            <OOBE>
28
-                <HideEULAPage>true</HideEULAPage>
29
-            </OOBE>
30
-        </component>
31
-        <component name="Microsoft-Windows-International-Core" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
32
-            <InputLocale>en-US</InputLocale>
33
-            <SystemLocale>en-US</SystemLocale>
34
-            <UILanguage>en-US</UILanguage>
35
-            <UserLocale>en-US</UserLocale>
36
-        </component>
37
-    </settings>
38
-    <settings pass="generalize">
39
-        <component name="Microsoft-Windows-Security-SPP" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
40
-            <SkipRearm>1</SkipRearm>
41
-        </component>
42
-    </settings>
43
-    <cpi:offlineImage cpi:source="wim:d:/aik/install.wim#Windows Server 2012 SERVERSTANDARDCORE" xmlns:cpi="urn:schemas-microsoft-com:cpi" />
44
-</unattend>

+ 0
- 51
Deployment/Unattended/ws-2012-full-unattend.xml View File

@@ -1,51 +0,0 @@
1
-<?xml version="1.0" encoding="utf-8"?>
2
-<unattend xmlns="urn:schemas-microsoft-com:unattend">
3
-    <settings pass="specialize">
4
-        <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
5
-            <TimeZone>Pacific Stantard Time</TimeZone>
6
-        </component>
7
-    </settings>
8
-    <settings pass="oobeSystem">
9
-        <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
10
-            <AutoLogon>
11
-                <Password>
12
-                    <Value>UABAAHMAcwB3ADAAcgBkAFAAYQBzAHMAdwBvAHIAZAA=</Value>
13
-                    <PlainText>false</PlainText>
14
-                </Password>
15
-                <LogonCount>1</LogonCount>
16
-                <Username>Administrator</Username>
17
-                <Enabled>true</Enabled>
18
-            </AutoLogon>
19
-            <UserAccounts>
20
-                <AdministratorPassword>
21
-                    <Value>UABAAHMAcwB3ADAAcgBkAEEAZABtAGkAbgBpAHMAdAByAGEAdABvAHIAUABhAHMAcwB3AG8AcgBkAA==</Value>
22
-                    <PlainText>false</PlainText>
23
-                </AdministratorPassword>
24
-            </UserAccounts>
25
-            <RegisteredOrganization>-</RegisteredOrganization>
26
-            <RegisteredOwner>-</RegisteredOwner>
27
-            <OOBE>
28
-                <HideEULAPage>true</HideEULAPage>
29
-            </OOBE>
30
-            <FirstLogonCommands>
31
-                <SynchronousCommand wcm:action="add">
32
-                    <RequiresUserInput>true</RequiresUserInput>
33
-                    <CommandLine>powershell.exe -File C:\Deploy\Scripts\FirstLogon.ps1</CommandLine>
34
-                    <Order>1</Order>
35
-                </SynchronousCommand>
36
-            </FirstLogonCommands>
37
-        </component>
38
-        <component name="Microsoft-Windows-International-Core" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
39
-            <InputLocale>en-US</InputLocale>
40
-            <SystemLocale>en-US</SystemLocale>
41
-            <UILanguage>en-US</UILanguage>
42
-            <UserLocale>en-US</UserLocale>
43
-        </component>
44
-    </settings>
45
-    <settings pass="generalize">
46
-        <component name="Microsoft-Windows-Security-SPP" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
47
-            <SkipRearm>1</SkipRearm>
48
-        </component>
49
-    </settings>
50
-    <cpi:offlineImage cpi:source="wim:d:/aik/install.wim#Windows Server 2012 SERVERSTANDARD" xmlns:cpi="urn:schemas-microsoft-com:cpi" />
51
-</unattend>

+ 0
- 28
Deployment/WindowsPowerShell/Modules/CoreFunctions/Config.ps1 View File

@@ -1,28 +0,0 @@
1
-<#
2
-Naming convention:
3
-
4
-== Normal variables
5
-** Set: $NormalVar = 123
6
-** Get: Write-Host $NormalVar
7
-
8
-== Script-scope variables
9
-** Set: $script:__ScriptScopeVar = 123
10
-** Get: Write-Host $__ScriptScopeVar
11
-
12
-== Global-scope variables
13
-** Set: $global:__GlobalScopeVar__ = 123
14
-** Get: Write-Host $__GlobalScopeVar__
15
-#>
16
-
17
-$script:__ModulePath = $PsScriptRoot
18
-$script:__ModuleName = $PsScriptRoot.Split("\")[-1]
19
-$script:__DefaultLogPath = [IO.Path]::Combine([IO.Path]::GetTempPath(), "PowerShell_$__ModuleName.log")
20
-
21
-
22
-$script:__RequiredModules = @("ServerManager", "DnsClient")
23
-$script:__ImportModulesExplicitely = $true
24
-$script:__ImportModulesErrorAction = "Stop"
25
-
26
-
27
-$global:__StopExecutionPreference__ = "Exit"
28
-

BIN
Deployment/WindowsPowerShell/Modules/CoreFunctions/CoreFunctions.psd1 View File


+ 0
- 36
Deployment/WindowsPowerShell/Modules/CoreFunctions/CoreFunctions.psm1 View File

@@ -1,36 +0,0 @@
1
-# Import config first
2
-. "$PsScriptRoot\Config.ps1"
3
-
4
-# Import functions from 'Include' subfolder
5
-Get-ChildItem "$PsScriptRoot\Include" -Filter "*.ps1" |
6
-    ForEach-Object {
7
-        . "$($_.FullName)"
8
-    }
9
-
10
-trap { Stop-Execution $_ }
11
-
12
-Export-ModuleMember -Function * -Alias *
13
-
14
-<#
15
-if ($__ImportModulesExplicitely) {
16
-    foreach ($Module in $__RequiredModules) {
17
-        Write-Log "Importing module '$Module' ..."
18
-        Import-Module -Name "$Module" -ErrorAction "$__ImportModulesErrorAction"
19
-    }
20
-}
21
-#>
22
-
23
-Write-Log "Module loaded from '$PsScriptRoot'"
24
-
25
-#-------------------------------------------------------------------------------
26
-
27
-switch ($Args[0]) {
28
-    'installTo' {
29
-        Install-Module -InstallPath $args[1] -ModulePath $PsScriptRoot
30
-    }
31
-    'register' {
32
-        Register-Module "$PsScriptRoot"
33
-    }
34
-    default {
35
-    }
36
-}

BIN
Deployment/WindowsPowerShell/Modules/CoreFunctions/Ionic.Zip.dll View File


+ 0
- 0
Deployment/WindowsPowerShell/Modules/CoreFunctions/en-US/about_CoreFunctions.help.txt View File


+ 0
- 99
Deployment/WindowsPowerShell/Modules/CoreFunctions/include/Base64.ps1 View File

@@ -1,99 +0,0 @@
1
-
2
-Function ConvertTo-Base64String {
3
-<#
4
-#>
5
-    [CmdletBinding(DefaultParameterSetName="FromString")]
6
-    param (
7
-        [Parameter(Position=1,ParameterSetName="FromString")]
8
-        [String] $String,
9
-        
10
-        [Parameter(ParameterSetName="FromFile")]
11
-        [String] $Path,
12
-        
13
-        [Parameter(ParameterSetName="FromFile")]
14
-        [Int] $ChunkSize = 5KB,
15
-
16
-        [Parameter(ParameterSetName="FromFile")]
17
-        [Switch] $OneChunk
18
-    )
19
-    switch($PSCmdlet.ParameterSetName) {
20
-        "FromString" {
21
-            [System.Text.Encoding]::UTF8.GetBytes($String)
22
-            [System.Convert]::ToBase64String($Bytes)
23
-        }
24
-        "FromFile" {
25
-            $FileStream = [IO.File]::Open($Path, [System.IO.FileMode]::Open)
26
-            $BytesToRead = $FileStream.Length
27
-            
28
-            if ($OneChunk) {
29
-                $ChunkSize = $BytesToRead
30
-            }
31
-            
32
-            $Bytes = New-Object Byte[] $ChunkSize
33
-            while ($BytesToRead -gt 0) {
34
-                if ($BytesToRead -lt $ChunkSize) {
35
-                    $ChunkSize = $BytesToRead
36
-                    $Bytes = New-Object Byte[] $ChunkSize
37
-                }
38
-                #Write-Host ("BytesToRead: {0}, ChunkSize: {1}" -f $BytesToRead, $ChunkSize )
39
-                $BytesRead = $FileStream.Read($Bytes, 0, $ChunkSize)
40
-                $BytesToRead -= $BytesRead
41
-                
42
-                [System.Convert]::ToBase64String($Bytes)
43
-            }
44
-            $FileStream.Close()
45
-        }
46
-    }
47
-}
48
-
49
-
50
-
51
-Function ConvertFrom-Base64String {
52
-<#
53
-#>
54
-    [CmdletBinding(DefaultParameterSetName="ToByteArray")]
55
-    param (
56
-        [Parameter(Position=1,ValueFromPipeline=$true)]
57
-        [String] $Base64String,
58
-        
59
-        [Parameter(ParameterSetName="ToFile")]
60
-        [String] $Path,
61
-        
62
-        [Parameter(ParameterSetName="ToString")]
63
-        [Switch] $ToString
64
-    )
65
-    begin {
66
-        switch($PSCmdlet.ParameterSetName) {
67
-            "ToFile" {
68
-                if ([IO.File]::Exists($Path)) {
69
-                    [IO.File]::Delete($Path)
70
-                }
71
-                $FileStream = [IO.File]::Open($Path, [IO.FileMode]::Append)
72
-            }
73
-        }
74
-    }
75
-    process {
76
-        foreach( $Line in ($Base64String -split '\n')) {
77
-            $Bytes  = [System.Convert]::FromBase64String($Line)
78
-
79
-            switch($PSCmdlet.ParameterSetName) {
80
-                "ToFile" {
81
-                    $FileStream.Write($Bytes, 0, $Bytes.Length)
82
-                }
83
-                "ToString" {
84
-                    [System.Text.Encoding]::UTF8.GetString($Bytes)
85
-                }
86
-                "ToByteArray" {
87
-                    $Bytes
88
-                }
89
-            }
90
-        }
91
-    }
92
-    end {
93
-        switch($PSCmdlet.ParameterSetName) {
94
-            "ToFile" {
95
-                $FileStream.Close()
96
-            }
97
-        }
98
-    }
99
-}

+ 0
- 388
Deployment/WindowsPowerShell/Modules/CoreFunctions/include/Functions.ps1 View File

@@ -1,388 +0,0 @@
1
-Function Stop-Execution {
2
-<#
3
-.SYNOPSIS
4
-Breaks execution with specified error code.
5
-
6
-.DESCRIPTION
7
-Function break script execution with error code provided. Error code may be 0 in case of non-error stop.
8
-
9
-It also tries to parse ErrorRecord or Exception object (if provided) and logs this information.
10
-#>
11
-    [CmdletBinding(DefaultParameterSetName="Exception")]
12
-    
13
-	param (
14
-        [Parameter(Position=1,ParameterSetName="Exception")]
15
-		$InputObject = $null,
16
-        
17
-        [Parameter(ParameterSetName="ErrorString")]
18
-		[String] $ExitString = "",
19
-        
20
-        [Parameter(ParameterSetName="ErrorString")]
21
-		[Int] $ExitCode = 0,
22
-        
23
-        [Parameter(ParameterSetName="ErrorString")]
24
-		[Switch] $Success
25
-	)
26
-    
27
-    Function Exit-Function {
28
-        if ($ExitCode -eq 0) {
29
-            Write-LogInfo ( "STOP ({0}):`n{1}" -f $ExitCode, $ExitString )
30
-        }
31
-        else {
32
-            Write-LogFatal ( "STOP ({0}):`n{1}" -f $ExitCode,  $ExitString )
33
-        }
34
-        
35
-        Write-Log "__StopExecutionPreference__ = '$__StopExecutionPreference__'"
36
-        switch ("$__StopExecutionPreference__") {
37
-            "Exit" {
38
-                exit $ExitCode
39
-            }
40
-            "ThrowIfException" {
41
-                if ($InputObject -eq $null) {
42
-                    exit $ExitCode
43
-                }
44
-                else {
45
-                    throw $InputObject
46
-                }
47
-            }
48
-            "ThrowAlways" {
49
-                throw $InputObject
50
-            }
51
-            default {
52
-                throw "Unknown value for __StopExecutionPreference__: '$__StopExecutionPreference__'"
53
-            }
54
-        }
55
-    }
56
-
57
-    switch($PSCmdlet.ParameterSetName) {
58
-		"Exception" {
59
-            #----------
60
-            if ($InputObject -eq $null) {
61
-		        $ExitString = "***** SCRIPT INTERRUPTED *****"
62
-                $ExitCode = 255
63
-                Exit-Function
64
-            }
65
-            #----------
66
-        
67
-        
68
-            #----------
69
-    		try {
70
-    			$ErrorRecord = [System.Management.Automation.ErrorRecord] $InputObject
71
-<#
72
-                $ExitString = @"
73
-$($ErrorRecord.ToString())
74
-
75
-*** Invocation Info ***
76
-$($ErrorRecord.InvocationInfo.PositionMessage)
77
-
78
-*** CategoryInfo ***
79
-$($ErrorRecord.CategoryInfo.ToString())
80
-
81
-*** FullyQualifiedErrorId ***
82
-$($ErrorRecord.FullyQualifiedErrorId.ToString())
83
-
84
-*** ScriptStackTrace ***
85
-$($ErrorRecord.ScriptStackTrace.ToString())
86
-*** *** ***
87
-"@
88
-#>
89
-                $ExitString = Out-String -InputObject $InputObject
90
-                $ExitCode = 255
91
-                Exit-Function
92
-    		}
93
-    		catch {
94
-    			$ErrorRecord = $null
95
-    			Write-LogWarning "Unable to cast InputObject to [System.Management.Automation.ErrorRecord]"
96
-    		}
97
-            #----------
98
-            
99
-            
100
-            #----------
101
-    		try {
102
-    			$Exception = [System.Exception] $InputObject
103
-    			#$ExitString = $Exception.ToString()
104
-                $ExitString = Out-String -InputObject $InputObject
105
-                $ExitCode = 255
106
-                Exit-Function
107
-    		}
108
-    		catch {
109
-    			$Exception = $null
110
-    			Write-LogWarning "Unable to cast InputObject to [System.Exception]"
111
-    		}
112
-            #----------
113
-
114
-        
115
-            #----------
116
-    		try {
117
-    			$ExitString = Out-String -InputObject $InputObject
118
-                $ExitCode = 255
119
-                Exit-Function
120
-    		}
121
-    		catch {
122
-    			Write-LogWarning "Unable to cast InputObject of type [$($InputObject.GetType())] to any of supported types."
123
-    		}
124
-            #----------
125
-        }
126
-        "ErrorString" {
127
-            if ($Success) {
128
-                $ExitString = "Script stopped with NO ERROR."
129
-                $ExitCode = 0
130
-            }
131
-            
132
-            Exit-Function
133
-        }
134
-    }
135
-    
136
-    $ExitString = "Unknown error occured in Stop-Execution"
137
-    $ExitCode = 255
138
-    Exit-Function
139
-}
140
-
141
-
142
-
143
-Function Get-PasswordAsSecureString {
144
-<#
145
-.SYNOPSIS
146
-Convert to / request password as secure string.
147
-#>
148
-    [CmdletBinding()]
149
-    param (
150
-        [String] $Password = "",
151
-        [String] $Prompt = "Please enter password"
152
-    )
153
-    
154
-    if ($Password -eq "") {
155
-        Read-Host -Prompt $Prompt -AsSecureString
156
-    }
157
-    else {
158
-        ConvertTo-SecureString -String "$Password" -AsPlainText -Force
159
-    }
160
-}
161
-
162
-
163
-
164
-Function New-Credential {
165
-<#
166
-.SYNOPSIS
167
-Create new creadential object with username and password provided.
168
-#>
169
-    [CmdletBinding()]
170
-	param (
171
-		[Parameter(Mandatory=$true)]
172
-		[String] $UserName,
173
-		
174
-		[String] $Password
175
-	)
176
-	
177
-	$SecurePassword = Get-PasswordAsSecureString -Password "$Password"
178
-	New-Object System.Management.Automation.PSCredential( "$UserName", $SecurePassword )
179
-}
180
-
181
-
182
-
183
-Function Invoke-WMSettingsChange {
184
-    if (-not ("win32.nativemethods" -as [type])) {
185
-        # Import SendMessageTimeout from Win32
186
-        Add-Type -Namespace Win32 -Name NativeMethods -MemberDefinition @"
187
-[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
188
-public static extern IntPtr SendMessageTimeout(
189
-    IntPtr hWnd, uint Msg, UIntPtr wParam, string lParam,
190
-    uint fuFlags, uint uTimeout, out UIntPtr lpdwResult);
191
-"@
192
-    }
193
-
194
-    $HWND_BROADCAST = [IntPtr]0xFFFF
195
-    $WM_SETTINGCHANGE = 0x001A
196
-    $result = [UIntPtr]::Zero
197
-
198
-    # Notify all windows of environment block change
199
-    Write-Log "Executing 'SendMessageTimeout' ..."
200
-
201
-    $retval = [Win32.NativeMethods]::SendMessageTimeout($HWND_BROADCAST, $WM_SETTINGCHANGE,
202
-	    [UIntPtr]::Zero, "Environment", 2, 5000, [ref] $result)
203
-    
204
-    Write-Log "'SendMessageTimeout' returned '$retval' (non-zero is OK)"
205
-}
206
-
207
-
208
-
209
-Function Start-Program {
210
-	param (
211
-		[String] $FilePath,
212
-		[String[]] $ArgumentList = @(' '),
213
-		[Int] $Timeout = 0,
214
-		[Switch] $NoWait,
215
-		[Switch] $PassThru,
216
-        [String] $WorkingDir = (Get-Location).ProviderPath
217
-	)
218
-
219
-	trap {
220
-		Write-LogError $_.Exception.Message
221
-		return $null
222
-	}
223
-
224
-	Write-Log "Starting program: $FilePath $ArgumentList"
225
-		
226
-	$ProcessStartInfo = New-Object System.Diagnostics.ProcessStartInfo
227
-	$ProcessStartInfo.FileName = $FilePath
228
-	$ProcessStartInfo.Arguments = $ArgumentList
229
-	$ProcessStartInfo.CreateNoWindow = $true
230
-	$ProcessStartInfo.RedirectStandardOutput = $true
231
-	$ProcessStartInfo.RedirectStandardError = $true
232
-	$ProcessStartInfo.UseShellExecute = $false
233
-    $ProcessStartInfo.WorkingDirectory = $WorkingDir
234
-		
235
-	$Process = [System.Diagnostics.Process]::Start($ProcessStartInfo)
236
-		
237
-	if ($NoWait) {
238
-		if ($PassThru) {
239
-			return $Process
240
-		}
241
-		else {
242
-			return $null
243
-		}
244
-	}
245
-	else {
246
-		if ($Timeout -eq 0) {
247
-			$Process.WaitForExit()
248
-		}
249
-		else {
250
-			$Process.WaitForExit($Timeout)
251
-		}
252
-	}
253
-	
254
-    $ProcessResult = New-Object PSObject |
255
-        Add-Member -Name "ExitCode" -MemberType NoteProperty -Value $Process.ExitCode -PassThru |
256
-        Add-Member -Name "StdOut" -MemberType NoteProperty -Value $Process.StandardOutput.ReadToEnd() -PassThru |
257
-        Add-Member -Name "StdErr" -MemberType NoteProperty -Value $Process.StandardError.ReadToEnd() -PassThru
258
-    
259
-	$Process = $null
260
-    
261
-    Write-Log ( "STDOUT:`n{0}" -f $ProcessResult.StdOut )
262
-    Write-Log ":STDOUT"
263
-		
264
-	Write-Log ( "STDERR:`n{0}" -f $ProcessResult.StdErr )
265
-    Write-Log ":STDERR"
266
-		
267
-	Write-Log "Program has finished with exit code ($($ProcessResult.ExitCode))"
268
-
269
-	if ($PassThru) {
270
-		return $ProcessResult
271
-	}
272
-	else {
273
-		return $null
274
-	}
275
-}
276
-New-Alias -Name Exec -Value Start-Program
277
-
278
-
279
-
280
-Function Backup-File {
281
-    param (
282
-        [String] $Path
283
-    )
284
-
285
-    $BackupFile = "$Path.bak"
286
-    
287
-    if (-not [IO.File]::Exists($Path)) {
288
-        Write-LogError "Unable to backup file '$Path': file not exists."
289
-        return
290
-    }
291
-    
292
-    if ([IO.File]::Exists($BackupFile)) {
293
-        try {
294
-            [IO.File]::Delete($BackupFile)
295
-        }
296
-        catch {
297
-            Write-LogError "Unable to delete existing .bak file '$BackupFile'."
298
-            return
299
-        }
300
-    }
301
-
302
-    Write-Log "Backing up file '$Path' to '$BackupFile'"
303
-    [IO.File]::Copy($Path, $BackupFile, $true)
304
-}
305
-
306
-
307
-
308
-Function Install-Module {
309
-    param (
310
-        [String] $InstallPath,
311
-        [String] $ModulePath,
312
-        [String] $ModuleName
313
-    )
314
-
315
-    if ($ModuleName -eq "") {
316
-        if ($ModulePath -eq "") {
317
-            Stop-Execution -ExitString "Don't know which module should be installed."
318
-        }
319
-        else {
320
-             $ModuleName = $ModulePath.Split("\")[-1]
321
-        }
322
-    }
323
-    
324
-    if ($InstallPath -eq "") {
325
-        Stop-Execution -ExitString "To install the module destination path must be provided."
326
-    }
327
-    else {
328
-        Write-Log "Installing the module to '$InstallPath'"
329
-        
330
-        $NewModulePath = [IO.Path]::Combine($InstallPath, $ModuleName)
331
-        if ([IO.Directory]::Exists($NewModulePath)) {
332
-            [IO.Directory]::Delete($NewModulePath, $true)
333
-        }
334
-            
335
-        Copy-Item -Path $ModulePath -Destination $InstallPath -Recurse -Force -ErrorAction Stop
336
-            
337
-        Update-PsModulePath -AddPath "$InstallPath"
338
-    }
339
-}
340
-
341
-
342
-
343
-Function Register-Module {
344
-    param (
345
-        [String] $ModulePath
346
-    )
347
-    $ModuleRoot = Split-Path -Path $ModulePath -Parent
348
-    Write-Log "Registering the module at '$ModuleRoot'"
349
-    Update-PsModulePath -AddPath "$ModuleRoot"
350
-}
351
-
352
-
353
-
354
-function Test-ModuleVersion {
355
-<#
356
-.SYNOPSIS
357
-Test module version.
358
-
359
-.DESCRIPTION
360
-Function specified module (current module by default), and compares it's version to version provided.
361
-Returned values:
362
-* -2 : error occured
363
-* -1 : module's version is lower than one provided
364
-*  0 : module's version is equal to one provided
365
-*  1 : module's version is greater than one provided
366
-#>
367
-    param (
368
-        [String] $Name = "$__ModuleName",
369
-        [String] $Version
370
-    )
371
-
372
-    $ModuleVersion = (Get-Module -Name $Name -ListAvailable).Version
373
-    
374
-    if ($ModuleVersion -eq $null) {
375
-        Write-Log "Module '$Name' not found."
376
-        return -2
377
-    }
378
-    
379
-    try {
380
-        $RequiredVersion = [System.Version]::Parse($Version)
381
-    }
382
-    catch {
383
-        Write-Log "'$Version' is not a correct version string."
384
-        return -2
385
-    }
386
-    
387
-    $ModuleVersion.CompareTo($RequiredVersion)
388
-}

+ 0
- 137
Deployment/WindowsPowerShell/Modules/CoreFunctions/include/Logger.ps1 View File

@@ -1,137 +0,0 @@
1
-Function Initialize-Logger {
2
-    param (
3
-        [String] $ModuleName = $__ModuleName,
4
-        [String] $LogPath = $__DefaultLogPath
5
-    )
6
-    
7
-    if (-not ("log4net.LogManager" -as [type])) {
8
-        $FileStream = ([System.IO.FileInfo] (Get-Item "$__ModulePath\log4net.dll")).OpenRead()
9
-
10
-        $AssemblyBytes = New-Object Byte[] $FileStream.Length
11
-        [Void] $FileStream.Read($AssemblyBytes, 0, $FileStream.Length)
12
-
13
-        $FileStream.Close()
14
-
15
-        [Void] [System.Reflection.Assembly]::Load($AssemblyBytes)
16
-    }
17
-
18
-    [log4net.GlobalContext]::Properties["LogPath"] = $LogPath
19
-    [log4net.GlobalContext]::Properties["ModuleName"] = $ModuleName
20
-
21
-    $script:__Logger = [log4net.LogManager]::GetLogger("PowerShell")
22
-
23
-    $Log4NetConfig = New-Object System.IO.FileInfo("$__ModulePath\log4net.config")
24
-
25
-    [log4net.Config.XmlConfigurator]::Configure($Log4NetConfig)
26
-    
27
-    $__Logger.info("Logger initialized. Log file: '$LogPath'`n")
28
-}
29
-
30
-
31
-Function Out-LogInfo {
32
-    param (
33
-        [Parameter(ValueFromPipeline=$true)]
34
-        $InputObject,
35
-        [Switch] $EntireObject
36
-    )
37
-    process {
38
-        if ($EntireObject) {
39
-            $__Logger.info("`n$(Out-String -InputObject $InputObject)")
40
-        }
41
-        else {
42
-            foreach ($Object in $InputObject) {
43
-                $__Logger.info((Out-String -InputObject $Object))
44
-            }
45
-        }
46
-    }
47
-}
48
-New-Alias -Name Out-Log -Value Out-LogInfo
49
-New-Alias -Name Write-Log -Value Out-LogInfo
50
-
51
-
52
-
53
-Function Out-LogWarning {
54
-    param (
55
-        [Parameter(ValueFromPipeline=$true)]
56
-        $InputObject,
57
-        [Switch] $EntireObject
58
-    )
59
-    process {
60
-        if ($EntireObject) {
61
-            $__Logger.warn("`n$(Out-String -InputObject $InputObject)")
62
-        }
63
-        else {
64
-            foreach ($Object in $InputObject) {
65
-                $__Logger.warn((Out-String -InputObject $Object))
66
-            }
67
-        }
68
-    }
69
-}
70
-New-Alias -Name Write-LogWarning -Value Out-LogWarning
71
-
72
-
73
-
74
-Function Out-LogError {
75
-    param (
76
-        [Parameter(ValueFromPipeline=$true)]
77
-        $InputObject,
78
-        [Switch] $EntireObject
79
-    )
80
-    process {
81
-        if ($EntireObject) {
82
-            $__Logger.error("`n$(Out-String -InputObject $InputObject)")
83
-        }
84
-        else {
85
-            foreach ($Object in $InputObject) {
86
-                $__Logger.error((Out-String -InputObject $Object))
87
-            }
88
-        }
89
-    }
90
-}
91
-New-Alias -Name Write-LogError -Value Out-LogError
92
-
93
-
94
-
95
-Function Out-LogFatal {
96
-    param (
97
-        [Parameter(ValueFromPipeline=$true)]
98
-        $InputObject,
99
-        [Switch] $EntireObject
100
-    )
101
-    process {
102
-        if ($EntireObject) {
103
-            $__Logger.fatal("`n$(Out-String -InputObject $InputObject)")
104
-        }
105
-        else {
106
-            foreach ($Object in $InputObject) {
107
-                $__Logger.fatal((Out-String -InputObject $Object))
108
-            }
109
-        }
110
-    }
111
-}
112
-New-Alias -Name Write-LogFatal -Value Out-LogFatal
113
-
114
-
115
-
116
-Function Out-LogDebug {
117
-    param (
118
-        [Parameter(ValueFromPipeline=$true)]
119
-        $InputObject,
120
-        [Switch] $EntireObject
121
-    )
122
-    process {
123
-        if ($EntireObject) {
124
-            $__Logger.debug("`n$(Out-String -InputObject $InputObject)")
125
-        }
126
-        else {
127
-            foreach ($Object in $InputObject) {
128
-                $__Logger.debug((Out-String -InputObject $Object))
129
-            }
130
-        }
131
-    }
132
-}
133
-New-Alias -Name Write-LogDebug -Value Out-LogDebug
134
-
135
-
136
-
137
-Initialize-Logger

+ 0
- 0
Deployment/WindowsPowerShell/Modules/CoreFunctions/include/Module.ps1 View File


+ 0
- 814
Deployment/WindowsPowerShell/Modules/CoreFunctions/include/NotCoreFunctions.ps1 View File

@@ -1,814 +0,0 @@
1
-Function Set-LocalUserPassword {
2
-    param (
3
-        [String] $UserName,
4
-        [String] $Password,
5
-        [Switch] $Force
6
-    )
7
-    
8
-    trap { Stop-Execution $_ }
9
-    
10
-    if ((Get-WmiObject Win32_UserAccount -Filter "LocalAccount = 'True' AND Name='$UserName'") -eq $null) {
11
-        throw "Unable to find local user account '$UserName'"
12
-    }
13
-    
14
-    if ($Force) {
15
-        Write-Log "Changing password for user '$UserName' to '*****'" # :)
16
-        ([ADSI] "WinNT://./$UserName").SetPassword($Password) | Out-Null
17
-    }
18
-    else {
19
-        Write-LogWarning "You are trying to change the password for the user '$UserName'. To do this please run the command again with -Force parameter."
20
-    }
21
-}
22
-
23
-
24
-
25
-Function Set-AutoLogonCredentials {
26
-	param (
27
-		[String] $DomainName,
28
-		[String] $UserName,
29
-		[String] $Password
30
-	)
31
-	
32
-	$KeyName = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon"
33
-
34
-	if ($DomainName -ne "") {
35
-		$UserName = "$DomainName\$UserName"
36
-	}
37
-    
38
-    Write-Log "Setting AutoLogon credentials ..."
39
-	try {
40
-    	[Microsoft.Win32.Registry]::SetValue($KeyName, "DefaultUserName", "$UserName", [Microsoft.Win32.RegistryValueKind]::String)
41
-    	[Microsoft.Win32.Registry]::SetValue($KeyName, "DefaultPassword", "$Password", [Microsoft.Win32.RegistryValueKind]::String)
42
-    	[Microsoft.Win32.Registry]::SetValue($KeyName, "AutoAdminLogon", "1", [Microsoft.Win32.RegistryValueKind]::String)
43
-    	[Microsoft.Win32.Registry]::SetValue($KeyName, "ForceAutoLogon", "1", [Microsoft.Win32.RegistryValueKind]::String)
44
-    }
45
-    catch {
46
-        Write-LogError "FAILED"
47
-        return
48
-    }
49
-    
50
-    Write-Log "SUCCESS"
51
-}
52
-
53
-
54
-
55
-Function Join-Domain {
56
-<#
57
-.SYNOPSIS
58
-Executes "Join domain" action.
59
-#>
60
-	param (
61
-		[String] $DomainName,
62
-		[String] $UserName,
63
-		[String] $Password,
64
-        [Switch] $AllowRestart
65
-	)
66
-	
67
-	$Credential = New-Credential -UserName "$DomainName\$UserName" -Password $Password
68
-
69
-	# Add the computer to the domain
70
-	if (Test-ComputerName -DomainName $DomainName) {
71
-		#Stop-Execution -Success -ExitString "Computer already joined to domain '$DomainName'"
72
-        Write-LogWarning "Computer already joined to domain '$DomainName'"
73
-	}
74
-	else {
75
-		Write-Log "Joining computer to domain '$DomainName' ..."
76
-		
77
-		Add-Computer -DomainName $DomainName -Credential $Credential -Force -ErrorAction Stop
78
-		
79
-        if ($AllowRestart) {
80
-            Write-Log "Restarting computer ..."
81
-            Restart-Computer -Force
82
-        }
83
-        else {
84
-		    #Stop-Execution -ExitCode 3010 -ExitString "Please restart the computer now."
85
-            Write-Log "Please restart the computer now."
86
-        }
87
-	}
88
-}
89
-
90
-
91
-
92
-Function Expand-Template {
93
-    param (
94
-        [String] $TemplateFile,
95
-        [String] $OutputFile,
96
-        [System.Collections.Hashtable] $ReplacementList,
97
-        [String] $Encoding = "Ascii"
98
-    )
99
-    
100
-    if (-not [IO.File]::Exists($TemplateFile)) {
101
-        Write-Error "File '$TemplateFile' not exists"
102
-        return $null
103
-    }
104
-    
105
-    if ([IO.File]::Exists($OutputFile)) {
106
-        [IO.File]::Delete($OutputFile)
107
-    }
108
-    
109
-    Get-Content $TemplateFile -Encoding $Encoding |
110
-        ForEach-Object {
111
-            $Line = $_
112
-            foreach ($Key in $ReplacementList.Keys) {
113
-                $Line = $Line.Replace("%_$($Key)_%", $ReplacementList[$Key])
114
-            }
115
-            Add-Content -Path $OutputFile -Encoding $Encoding -Value $Line
116
-        }
117
-}
118
-
119
-
120
-
121
-Function Add-WindowsFeatureWrapper {
122
-<#
123
-.SYNOPSIS
124
-Wraps Install-WindowsFeature function.
125
-
126
-.DESCRIPTION
127
-This function adds some logic to multiple feature installation.
128
-
129
-It fails if any of required features fails.
130
-
131
-It reports that reboot required if it is required, or restarts the computer.
132
-#>
133
-	param (
134
-		[Parameter(Mandatory=$true)]
135
-		[String[]] $Name,
136
-		[Switch] $IncludeManagementTools,
137
-		[Switch] $AllowRestart,
138
-        [Switch] $NotifyRestart
139
-	)
140
-	
141
-    $RestartNeeded = $false
142
-    
143
-	foreach ($Feature in $Name) {
144
-		Write-Log "Installing feature '$Feature' ..."
145
-		$Action = Install-WindowsFeature `
146
-			-Name $Feature `
147
-			-IncludeManagementTools:$IncludeManagementTools `
148
-			-ErrorAction Stop
149
-		
150
-		if ($Action.Success -eq $true) {
151
-			if ($Action.FeatureResult.RestartNeeded -eq $true) {
152
-				Write-LogWarning "Restart required"
153
-				$RestartNeeded = $true
154
-			}
155
-			Write-Log "Feature '$Feature' installed successfully"
156
-		}
157
-		else {
158
-			Stop-Execution "Failed to install feature '$Feature'"
159
-		}
160
-	}
161
-	
162
-    if ($RestartNeeded) {
163
-        Write-Log "Restart required to finish feature(s) installation."
164
-        if ($AllowRestart) {
165
-            Write-Log "Restarting computer ..."
166
-            Restart-Computer -Force
167
-        }
168
-        elseif ($NotifyRestart) {
169
-            Stop-Execution -ExitCode 3010 -ExitString "Please restart the computer now."
170
-        }
171
-    }
172
-}
173
-
174
-
175
-
176
-Function Test-WmiReturnValue {
177
-<#
178
-.SYNOPSIS
179
-Check the ReturnValue property of the object provided.
180
-
181
-.DESCRIPTION
182
-This funciton checks if ReturnValue property is equal to 0.
183
-
184
-=== TODO ===
185
-If it is not, then funtion should try to provide desctiption for the error code based on the WMI object type.
186
-WMI object type must be provided explicitely.
187
-#>
188
-	param (
189
-		[Parameter(ValueFromPipeline=$true,Mandatory=$true)]
190
-		$InputObject,
191
-		[String] $Type = ""
192
-	)
193
-		
194
-	try {
195
-		$ReturnValue = $InputObject.ReturnValue
196
-	}
197
-	catch {
198
-		throw "Property 'ReturnValue' not found on this object"
199
-	}
200
-		
201
-	if ($ReturnValue -eq 0) {
202
-		Write-Log "WMI operation completed successfully"
203
-	}
204
-	else {
205
-		throw "Operation failed with status code = $ReturnValue"
206
-	}
207
-}
208
-
209
-
210
-
211
-Function Set-NetworkAdapterConfiguration {
212
-<#
213
-.SYNOPSIS
214
-Set network adapter configuration.
215
-
216
-.DESCRIPTION
217
-
218
-
219
-.EXAMPLE
220
-PS> Set-NetworkAdapterConfiguration -MACAddress aa:bb:cc:dd:ee:ff -Auto
221
-
222
-Convert "dynamic" parameters (DHCP) to "static" (manual) for network adapter with MAC address aa:bb:cc:dd:ee:ff
223
-
224
-.EXAMPLE
225
-PS> Set-NetworkAdapterConfiguration -MACAddress aa:bb:cc:dd:ee:ff -DNSServer "192.168.0.1","192.168.0.2"
226
-
227
-Configure DNS servers list for network adapter with MAC address aa:bb:cc:dd:ee:ff
228
-
229
-#>
230
-	param (
231
-		[String] $MACAddress = "",
232
-		
233
-		[Parameter(ParameterSetName="ManualConfig")]
234
-		[String] $IPAddress = "",
235
-		
236
-		[Parameter(ParameterSetName="ManualConfig")]
237
-		[String] $IPNetmask = "",
238
-		
239
-		[Parameter(ParameterSetName="ManualConfig")]
240
-		[String[]] $IPGateway = @(),
241
-		
242
-		[Parameter(ParameterSetName="ManualConfig")]
243
-		[String[]] $DNSServer = @(),
244
-		
245
-		[Parameter(ParameterSetName="ManualConfig")]
246
-		[Switch] $FirstAvailable,
247
-
248
-		[String] $Name = "",
249
-		
250
-		[Parameter(ParameterSetName="AutoConfig",Mandatory=$true)]
251
-		[Switch] $Auto,
252
-
253
-		[Parameter(ParameterSetName="AutoConfig")]
254
-		[Switch] $All
255
-	)
256
-    
257
-	Write-Log "Configuring network adapter(s) ..."
258
-    
259
-	:SetIPAddress switch($PSCmdlet.ParameterSetName) {
260
-		"AutoConfig" {
261
-            Write-Log "'auto' mode"
262
-            
263
-			$IPv4RegExp = "\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}"
264
-			
265
-			if ($All -eq $true) {
266
-				$Filter = { $_.AdapterTypeId -eq 0 }
267
-				$Name = ""
268
-			}
269
-			else {
270
-				$Filter = { $_.MACAddress -eq $MACAddress }
271
-			}
272
-			
273
-			Get-WmiObject Win32_NetworkAdapter |
274
-				Where-Object $Filter |
275
-				ForEach-Object {
276
-					$NetworkAdapter = $_
277
-					$AdapterConfig = Get-WmiObject Win32_NetworkAdapterConfiguration |
278
-						Where-Object { $_.Index -eq $NetworkAdapter.DeviceId }
279
-					
280
-					Write-Log "Configuring '$($NetworkAdapter.Name)' ..."
281
-					
282
-					for ($i = 0; $i -lt $AdapterConfig.IPAddress.Length; $i++) {
283
-						if ($AdapterConfig.IPAddress[$i] -match $IPv4RegExp) {
284
-							$IPAddress = $AdapterConfig.IPAddress[$i]
285
-							$IPNetmask = $AdapterConfig.IPSubnet[$i]
286
-							$IPGateway = $AdapterConfig.DefaultIPGateway
287
-                            $DNSServer = $AdapterConfig.DNSServerSearchOrder
288
-							
289
-							Write-Log "Setting IP address ($IPAddress), netmask ($IPNetmask) ..."
290
-							$AdapterConfig.EnableStatic($IPAddress, $IPNetmask) | Out-Null
291
-                            
292
-                            Write-Log "Setting default gateways ($IPGateway) ..."
293
-							$AdapterConfig.SetGateways($IPGateway) | Out-Null
294
-                            
295
-                            Write-Log "Setting DNS servers ($DNSServer) ..."
296
-                            $AdapterConfig.SetDNSServerSearchOrder($DNSServer) | Out-Null
297
-						}
298
-					}
299
-                    
300
-                    Write-Log "'$($NetworkAdapter.Name)' configured"
301
-				}
302
-		}
303
-		"ManualConfig" {
304
-            Write-Log "'manual' mode"
305
-			if ( $FirstAvailable ) {
306
-                Write-Log "Selecting first available network adapter ..."
307
-				$NetworkAdapter = Get-WmiObject Win32_NetworkAdapter |
308
-					Where-Object { $_.AdapterTypeId -eq 0 } |
309
-					Select-Object -First 1
310
-			}
311
-			else {
312
-				$NetworkAdapter = Get-WmiObject Win32_NetworkAdapter |
313
-					Where-Object { $_.MACAddress -eq $MACAddress }
314
-			}
315
-			
316
-			if ( $NetworkAdapter -eq $null ) {
317
-				Write-LogError "Network adapter with MAC = '$MACAddress' not found."
318
-				return
319
-			}
320
-			
321
-			$AdapterConfig = Get-WmiObject Win32_NetworkAdapterConfiguration |
322
-				Where-Object { $_.Index -eq $NetworkAdapter.DeviceId }
323
-
324
-			if (($IPAddress -ne "") -and ($IPNetmask -ne "")) {
325
-				Write-Log "Configuring IP address / netmask for '$($NetworkAdapter.Name)' ..."
326
-				
327
-				<#
328
-				for ($i = 0; $i -lt $AdapterConfig.IPAddress.Length; $i++)
329
-				{
330
-					if (($AdapterConfig.IPAddress[$i] -eq $IPAddress) -and ($AdapterConfig.IPSubnet[$i] -eq $IPNetmask))
331
-					{
332
-						Write-Log "There is an adapter with required configuration."
333
-						break SetIPAddress
334
-					}
335
-				}
336
-				#>
337
-				Write-Log "Setting IP address $IPAddress, netmask $IPNetmask"
338
-				$AdapterConfig.EnableStatic("$IPAddress", "$IPNetmask") | Out-Null
339
-				
340
-				Write-Log "IP address configured."
341
-			}
342
-			
343
-			if ($IPGateway.Count -gt 0) {
344
-				Write-Log "Configuring IP gateway for '$($NetworkAdapter.Name)' ..."
345
-				
346
-				$AdapterConfig.SetGateways($IPGateway) | Out-Null
347
-				
348
-				Write-Log "IP gateway configured."
349
-			}
350
-			
351
-			if ($DNSServer.Count -gt 0) {
352
-				Write-Log "Configuring DNS server(s) for '$($NetworkAdapter.Name)' ..."
353
-				
354
-				$AdapterConfig.SetDNSServerSearchOrder($DNSServer) | Out-Null
355
-				
356
-				Write-Log "DNS configured."
357
-			}
358
-		}
359
-	}
360
-
361
-	if ($Name -ne "") {
362
-		Write-Log "Changing adapter name '$($NetworkAdapter.NetConnectionId)' --> '$Name'"
363
-		$NetworkAdapter.NetConnectionId = "$Name"
364
-		$NetworkAdapter.Put() | Out-Null
365
-	}
366
-}
367
-
368
-
369
-
370
-Function Show-EthernetNetworkAdapters {
371
-    Get-WmiObject Win32_NetworkAdapter -Filter "PhysicalAdapter = 'True' AND AdapterTypeId = '0'" |
372
-        Select-Object 'Index','MACAddress','NetConnectionId'
373
-}
374
-
375
-
376
-
377
-Function Test-ComputerName {
378
-<#
379
-.SYNOPSIS
380
-Test if computer name is set, and the computer belongs to specified domain / workgroup.
381
-
382
-.DESCRIPTION
383
-Function tests the following conditions:
384
-* the computer name is equal to the provided one
385
-* the computer is a part of domain
386
-* the computer belongs to the specified domain
387
-* the computer belongs to the specified workgroup
388
-
389
-Multiple checks are logically ANDed.
390
-#>
391
-    [CmdletBinding()]
392
-	param (
393
-		[String] $ComputerName,
394
-		[String] $DomainName,
395
-		[String] $WorkgroupName,
396
-		[Switch] $PartOfDomain
397
-	)
398
-	process {
399
-    	$ComputerSystem = Get-WmiObject Win32_ComputerSystem
400
-    	
401
-    	if (($ComputerName -ne "") -and ($ComputerSystem.Name -ne "$ComputerName")) {
402
-            Write-Error "ComputerName is not equal to '$ComputerName'"
403
-    		return $false
404
-    	}
405
-    	
406
-    	if (($DomainName -ne "") -and ($ComputerSystem.Domain -ne "$DomainName")) {
407
-            Write-Error "DomainName is not equal to '$DomainName'"
408
-    		return $false
409
-    	}
410
-    	
411
-    	if (($WorkgroupName -ne "") -and ($ComputerSystem.Workgroup -ne "$WorkgroupName")) {
412
-            Write-Error "WorkgroupName is not equal to '$WorkgroupName'"
413
-    		return $false
414
-    	}
415
-    	
416
-    	if (($PartOfDOmain -eq $true) -and ($ComputerSystem.PartOfDomain -eq $false)) {
417
-            Write-Error "Computer is not the part of any domain."
418
-    		return $false
419
-    	}
420
-    	
421
-    	return $true
422
-    }
423
-}
424
-
425
-
426
-
427
-Function Set-ComputerName {
428
-    param (
429
-        [String] $Name
430
-    )
431
-    
432
-    
433
-	# Rename the computer
434
-	if ($Name -ne "") {
435
-		if (Test-ComputerName -ComputerName $Name) {
436
-			Stop-Execution -Success -ExitString "Computer name already configured"
437
-		}
438
-		else {
439
-			Write-Log "Renaming computer to '$Name'"
440
-				
441
-			Rename-Computer -NewName $NewName -Force -ErrorAction Stop
442
-
443
-			Stop-Execution -ExitCode 3010 -ExitString "Please restart the computer now"
444
-		}
445
-	}
446
-}
447
-
448
-
449
-
450
-
451
-Function Resolve-LdapDnsName {
452
-    param (
453
-        [String] $DomainName
454
-    )
455
-    
456
-    Resolve-DNSName -Type "SRV" -Name "_ldap._tcp.dc._msdcs.$DomainName" |
457
-        Where-Object { $_.Type -eq "A" } |
458
-        Select-Object -Property Name,IPAddress
459
-}
460
-
461
-
462
-
463
-Function Wait-LdapServerAvailable {
464
-    param (
465
-        [String] $DomainName,
466
-        [Int] $PingSeqCountThreshold = 10,
467
-        [Int] $PingSeqPerHostThreshold = 5
468
-    )
469
-    
470
-    $LdapServerList = @( Resolve-LdapDnsName $DomainName )
471
-    Write-Log @( "Ldap server list:", ( $LdapServerList | Out-String ) )
472
-    
473
-    :MainLoop foreach ($LdapServer in $LdapServerList) {
474
-        $PingSeqCount = 0
475
-        $PingSeqPerHost = 0
476
-        while ($PingSeqPerHost -lt $PingSeqPerHostThreshold) {
477
-            if (Test-Connection -ComputerName $LdapServer.IpAddress -Count 1 -Quiet) {
478
-                Write-Log "Ping '$($LdapServer.Name)' OK"
479
-                $PingSeqCount++
480
-            }
481
-            else {
482
-                Write-Log "Ping '$($LdapServer.Name)' FAILED"
483
-                $PingSeqCount = 0
484
-                $PingSeqPerHost++
485
-            }
486
-            
487
-            if ($PingSeqCount -ge $PingSeqCountThreshold) {
488
-                Write-Log "Returning true"
489
-                return $true
490
-            }
491
-            
492
-            Start-Sleep -Seconds 1
493
-        }
494
-    }
495
-    
496
-    Write-Log "Returning false"
497
-    return $false
498
-}
499
-
500
-
501
-
502
-Function Get-ConfigDriveObject {
503
-    [CmdletBinding()]
504
-    param (
505
-        [Parameter(ParameterSetName="MetaData")]
506
-        [Switch] $MetaData,
507
-        
508
-        [Parameter(ParameterSetName="UserData")]
509
-        [Switch] $UserData,
510
-        
511
-        [Parameter(ParameterSetName="CustomObject")]
512
-        [String] $CustomObject,
513
-        
514
-        [String] $Path = "openstack/latest"
515
-    )
516
-    
517
-    $ConfigDrivePrefix = "http://169.254.169.154/$Path"
518
-    
519
-    try {
520
-        switch($PSCmdlet.ParameterSetName) {
521
-            "MetaData" {
522
-                $ConfigDriveObjectUrl = "$ConfigDrivePrefix/meta_data.json"
523
-                $MetaData = Invoke-WebRequest $ConfigDriveObjectUrl
524
-                ConvertFrom-Json $MetaData.Content
525
-            }
526
-            "UserData" {
527
-                $ConfigDriveObjectUrl = "$ConfigDrivePrefix/user_data"
528
-                $UserData = Invoke-WebRequest $ConfigDriveObjectUrl
529
-                $UserData.Content
530
-            }
531
-            "CustomObject" {
532
-                $ConfigDriveObjectUrl = "$ConfigDrivePrefix/$CustomObject"
533
-                $CustomObject = Invoke-WebRequest $ConfigDriveObjectUrl
534
-                $CustomObject.Content
535
-            }
536
-        }
537
-    }
538
-    catch {
539
-        Write-Error "Unable to retrieve object from 'ConfigDriveObjectUrl'"
540
-        return $null
541
-    }
542
-}
543
-
544
-
545
-
546
-Function Update-AgentConfig {
547
-    param (
548
-        [String] $RootPath = "C:\Keero\Agent"
549
-    )
550
-    
551
-    try {
552
-        $MetaData = Get-ConfigDriveObject -MetaData -ErrorAction Stop
553
-        if ($MetaData.meta -ne $null) {
554
-            Stop-Service "Keero Agent" -Force
555
-            Expand-Template -TemplateFile "$RootPath\WindowsAgent.exe.config.template" -OutputFile "$RootPath\WindowsAgent.exe.config" -ReplacementList $MetaData.meta
556
-            Start-Service "Keero Agent"
557
-        }
558
-    }
559
-    catch {
560
-        Write-LogError "Failed to update agent configuration"
561
-    }
562
-}
563
-
564
-
565
-
566
-Function Update-PsModulePath {
567
-    param (
568
-        [String] $AddPath = ""
569
-    )
570
-
571
-    $NewPsModulePath = (
572
-            @([Environment]::GetEnvironmentVariable("PsModulePath", [EnvironmentVariableTarget]::Machine) -split ";") + @($AddPath) `
573
-            | Select-Object -Unique
574
-        ) -join ';'
575
-    
576
-    [Environment]::SetEnvironmentVariable("PsModulePath", $NewPsModulePath, [EnvironmentVariableTarget]::Machine)
577
-    
578
-    Invoke-WMSettingsChange
579
-}
580
-
581
-
582
-
583
-Function Get-ModuleHelp {
584
-    param (
585
-        [String] $ModuleName = $__ModuleName,
586
-        [String] $Path = "",
587
-        [Switch] $File,
588
-        [Int] $Width = 80
589
-    )
590
-    
591
-	$sb = {
592
-        $Module = Get-Module $ModuleName
593
-    	
594
-    	"`n"
595
-        "Module: $($Module.Name)"
596
-    	"Module version: $($Module.Version)"
597
-    	"`n"
598
-        "{0} Module Description {0}" -f ('=' * 30)
599
-        "`n"
600
-        
601
-    	Get-Help "about_$($Module.Name)" | Out-String -Width $Width
602
-    	
603
-        "{0} Exported Functions {0}" -f ('=' * 30)
604
-        "`n"
605
-        	
606
-    	foreach ($CommandName in $Module.ExportedCommands.Keys) {
607
-            '-' * 80
608
-    		Get-Help -Name $CommandName -Detailed | Out-String -Width $Width
609
-    	}
610
-    }
611
-    
612
-    if (($File) -and ($Path -eq "")) {
613
-        $Path = [IO.Path]::GetTempFileName()
614
-    }
615
-    
616
-    if ($Path -ne "") {
617
-        & $sb | Out-File -FilePath $Path -Force
618
-    }
619
-    else {
620
-        & $sb | Out-Default
621
-    }
622
-    
623
-    if ($File) {
624
-        notepad.exe "$Path"
625
-    }
626
-}
627
-
628
-
629
-
630
-Function New-ModuleTemplate {
631
-    param (
632
-        [Parameter(Mandatory=$true)]
633
-        [String] $Name,
634
-        
635
-        [String] $Path = "$($Env:USERPROFILE)\Documents\WindowsPowerShell\Modules",
636
-        
637
-        [Switch] $Force
638
-    )
639
-    if ([IO.Directory]::Exists("$Path\$Name")) {
640
-        if ($Force) {
641
-            [IO.Directory]::Delete("$Path\$Name", $true)
642
-        }
643
-        else {
644
-            Write-Error "Folder '$Path\$Name' already exists. Remove it manually or specify -Force switch."
645
-            return
646
-        }
647
-    }
648
-    
649
-    
650
-    [IO.Directory]::CreateDirectory("$Path\$Name")
651
-    [IO.Directory]::CreateDirectory("$Path\$Name\en-US")
652
-    [IO.Directory]::CreateDirectory("$Path\$Name\include")
653
-    
654
-    
655
-    Set-Content -Path "$Path\$Name\en-US\about_$Name.help.txt" -Value @'
656
-'@
657
-
658
-    
659
-    Set-Content -Path "$Path\$Name\Config.ps1" -Value @'
660
-$script:__ModulePath = $PsScriptRoot
661
-$script:__ModuleName = $PsScriptRoot.Split("\")[-1]
662
-$script:__DefaultLogPath = [IO.Path]::Combine([IO.Path]::GetTempPath(), "PowerShell_$__ModuleName.log")
663
-
664
-$global:__StopExecutionExitsSession__ = $false
665
-'@    
666
-    
667
-    
668
-    Set-Content -Path "$Path\$Name\$Name.psm1" -Value @'
669
-# Import config first
670
-. "$PsScriptRoot\Config.ps1"
671
-
672
-# Import functions from 'Include' subfolder
673
-Get-ChildItem "$PsScriptRoot\Include" -Filter "*.ps1" |
674
-    ForEach-Object {
675
-        . "$($_.FullName)"
676
-    }
677
-
678
-Export-ModuleMember -Function * -Alias *
679
-
680
-Initialize-Logger -ModuleName $__ModuleName -LogPath $__DefaultLogPath
681
-
682
-Write-Log "Module loaded from '$PsScriptRoot'"
683
-'@
684
-    
685
-    
686
-    New-ModuleManifest `
687
-        -Path "$Path\$Name\$Name.psd1" `
688
-        -ModuleToProcess "$Name.psm1" `
689
-        -RequiredModules "CoreFunctions"
690
-    
691
-}
692
-
693
-
694
-
695
-function New-SqlServerConnection {
696
-    param (
697
-        [String] $ServerName,
698
-        [String] $UserName = '',
699
-        [String] $Password = '',
700
-        $Credentials,
701
-        [Switch] $SqlAuth
702
-    )
703
-
704
-    if ($Credentials -eq $null) {
705
-        if ($UserName -eq '') {
706
-            throw "User name must be provided in order to create credentials object!"
707
-        }
708
-        
709
-        $Credentials = New-Credential -UserName $UserName -Password $Password
710
-    }
711
-
712
-    $Server = New-Object `
713
-        -TypeName Microsoft.SqlServer.Management.Smo.Server `
714
-        -ArgumentList $ServerName
715
-    
716
-    $LoginName = $Credentials.UserName -replace("^\\", "")
717
-
718
-    try {
719
-        if ($SqlAuth) {
720
-            $Server.ConnectionContext.set_LoginSecure($false)
721
-            $Server.ConnectionContext.set_Login($LoginName)
722
-            $Server.ConnectionContext.set_SecurePassword($Credentials.Password)
723
-        }
724
-        else {
725
-            throw "Not implemented!"
726
-        }
727
-    }
728
-    catch {
729
-        return $null
730
-    }
731
-
732
-    $Server
733
-}
734
-
735
-
736
-
737
-function Import-SqlServerAssemblies {
738
-<#
739
-.SYNOPSIS
740
-Import assemblies required to work with Sql Server instance from PowerShell
741
-
742
-.DESCRIPTION
743
-Possible assembly list:
744
-    "Microsoft.SqlServer.Management.Common"
745
-    "Microsoft.SqlServer.Smo"
746
-    "Microsoft.SqlServer.Dmf"
747
-    "Microsoft.SqlServer.Instapi"
748
-    "Microsoft.SqlServer.SqlWmiManagement"
749
-    "Microsoft.SqlServer.ConnectionInfo"
750
-    "Microsoft.SqlServer.SmoExtended"
751
-    "Microsoft.SqlServer.SqlTDiagM"
752
-    "Microsoft.SqlServer.SString"
753
-    "Microsoft.SqlServer.Management.RegisteredServers"
754
-    "Microsoft.SqlServer.Management.Sdk.Sfc"
755
-    "Microsoft.SqlServer.SqlEnum"
756
-    "Microsoft.SqlServer.RegSvrEnum"
757
-    "Microsoft.SqlServer.WmiEnum"
758
-    "Microsoft.SqlServer.ServiceBrokerEnum"
759
-    "Microsoft.SqlServer.ConnectionInfoExtended"
760
-    "Microsoft.SqlServer.Management.Collector"
761
-    "Microsoft.SqlServer.Management.CollectorEnum"
762
-    "Microsoft.SqlServer.Management.Dac"
763
-    "Microsoft.SqlServer.Management.DacEnum"
764
-    "Microsoft.SqlServer.Management.Utility"
765
-
766
-.LINKS
767
-http://msdn.microsoft.com/en-us/library/cc281962%28v=sql.105%29.aspx
768
-#>
769
-    $AssemblyList = @(
770
-        "Microsoft.SqlServer.Smo"
771
-        "Microsoft.SqlServer.SmoExtended"
772
-    )
773
-        
774
-    foreach ($asm in $AssemblyList) {
775
-        [System.Reflection.Assembly]::LoadWithPartialName($asm) | Out-Null
776
-    }
777
-}
778
-
779
-
780
-
781
-function Import-SqlServerProvider {
782
-    $SqlPsReg="HKLM:\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.SqlServer.Management.PowerShell.sqlps"
783
-
784
-    if (Get-ChildItem $SqlPsReg -ErrorAction "SilentlyContinue") {
785
-        throw "SQL Server Provider for Windows PowerShell is not installed."
786
-    }
787
-    else {
788
-        $Item = Get-ItemProperty $SqlPsReg
789
-        $SqlPsPath = [System.IO.Path]::GetDirectoryName($Item.Path)
790
-    }
791
-
792
-    #
793
-    # Set mandatory variables for the SQL Server provider
794
-    #
795
-    $global:SqlServerMaximumChildItems = 0
796
-    $global:SqlServerConnectionTimeout = 30
797
-    $global:SqlServerIncludeSystemObjects = $false
798
-    $global:SqlServerMaximumTabCompletion = 1000
799
-
800
-    #
801
-    # Load the snapins, type data, format data
802
-    #
803
-    Push-Location
804
-    Set-Location $sqlpsPath
805
-    
806
-    Add-PSSnapin SqlServerCmdletSnapin100
807
-    Add-PSSnapin SqlServerProviderSnapin100
808
-    
809
-    Update-TypeData -PrependPath SQLProvider.Types.ps1xml 
810
-    Update-FormatData -PrependPath SQLProvider.Format.ps1xml 
811
-    
812
-    Pop-Location
813
-}
814
-

+ 0
- 1
Deployment/WindowsPowerShell/Modules/CoreFunctions/include/SqlFunctions.ps1 View File

@@ -1 +0,0 @@
1
-

+ 0
- 69
Deployment/WindowsPowerShell/Modules/CoreFunctions/include/Zip.ps1 View File

@@ -1,69 +0,0 @@
1
-[Void] [System.Reflection.Assembly]::LoadFrom("$__ModulePath\Ionic.Zip.dll")
2
-
3
-
4
-Function Compress-Folder {
5
-<#
6
-#>
7
-    [CmdLetBinding()]
8
-    param (
9
-        [Parameter(Mandatory=$true)]
10
-        [String] $Path,
11
-
12
-        [String] $ZipFile = "",
13
-        
14
-        [Switch] $TempFile,
15
-        
16
-        [Switch] $ContentOnly
17
-    )
18
-    
19
-    if (-not [IO.Directory]::Exists($Path)) {
20
-        Write-LogError "Directory '$Path' not found."
21
-        return
22
-    }
23
-    
24
-    if ($TempFile) {
25
-        $ZipFile = [IO.Path]::GetTempFileName()
26
-    }
27
-    
28
-    if ($ZipFile -eq "") {
29
-        $ZipFile = "$Path.zip"
30
-    }
31
-    
32
-    if ([IO.File]::Exists($ZipFile)) {
33
-        [IO.File]::Delete($ZipFile)
34
-    }
35
-
36
-    $zip = New-Object Ionic.Zip.ZipFile
37
-    if ($ContentOnly) {
38
-        [Void] $zip.AddDirectory($Path)
39
-    }
40
-    else {
41
-        [Void] $zip.AddDirectory($Path, (Split-Path -Path $Path -Leaf))
42
-    }
43
-    $zip.Save($ZipFile)
44
-    $zip.Dispose()
45
-    
46
-    return $ZipFile
47
-}
48
-
49
-
50
-Function Expand-Zip {
51
-<#
52
-#>
53
-    [CmdletBinding()]
54
-    param (
55
-        [Parameter(Mandatory=$true)]
56
-        [String] $Path,
57
-
58
-        [String] $Destination
59
-    )
60
-    
61
-    if (-not [IO.File]::Exists($Path)) {
62
-        Write-LogError "File not found '$Path'"
63
-        return
64
-    }
65
-    
66
-    $zip = [Ionic.Zip.ZipFile]::Read($Path)
67
-    $zip.ExtractAll($Destination, [Ionic.Zip.ExtractExistingFileAction]::OverwriteSilently)
68
-    $zip.Dispose()
69
-}

+ 0
- 42
Deployment/WindowsPowerShell/Modules/CoreFunctions/log4net.config View File

@@ -1,42 +0,0 @@
1
-<log4net>
2
-	<appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender" >
3
-		<param name="File" type="log4net.Util.PatternString" value="%property{LogPath}" />
4
-		<param name="AppendToFile" value="true" />
5
-		<param name="RollingStyle" value="Size" />
6
-		<param name="MaxSizeRollBackups" value="100" />
7
-		<param name="MaximumFileSize" value="1024KB" />
8
-		<param name="StaticLogFileName" value="true" />
9
-		<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
10
-		<layout type="log4net.Layout.PatternLayout">               
11
-			<param name="ConversionPattern" value="%date [%-5level] [%property{ModuleName}] %message" />
12
-		</layout>
13
-	</appender>
14
-		
15
-	<appender name="ColoredConsoleAppender" type="log4net.Appender.ColoredConsoleAppender">
16
-		<mapping>
17
-			<level value="error" />
18
-			<foreColor value="Red, HighIntensity" />
19
-		</mapping>
20
-		<mapping>
21
-			<level value="warn" />
22
-			<foreColor value="Yellow, HighIntensity" />
23
-		</mapping>
24
-		<mapping>
25
-			<level value="info" />
26
-			<foreColor value="Green, HighIntensity" />
27
-		</mapping>
28
-		<layout type="log4net.Layout.PatternLayout">
29
-			<conversionPattern value="%date [%-5level] [%property{ModuleName}] %message" />
30
-		</layout>
31
-	</appender>
32
-
33
- 	<!--root>
34
-		<level value="info" />            
35
-	</root-->
36
-
37
-	<logger name="PowerShell" additivity="false">
38
-		<!--level value="info" /-->
39
-		<appender-ref ref="ColoredConsoleAppender" />
40
-		<appender-ref ref="RollingFileAppender" />
41
-	</logger>
42
-</log4net>

BIN
Deployment/WindowsPowerShell/Modules/CoreFunctions/log4net.dll View File


+ 0
- 11
Deployment/cloudbase-init/config/cloudbase-init.conf View File

@@ -1,11 +0,0 @@
1
-[DEFAULT]
2
-username=Admin
3
-groups=Administrators
4
-inject_user_password=false
5
-network_adapters=
6
-config_drive_raw_hdd=false
7
-config_drive_cdrom=false
8
-verbose=true
9
-logdir=C:\Program Files (x86)\Cloudbase Solutions\Cloudbase-Init\log\
10
-logfile=cloudbase-init.log
11
-plugins=cloudbaseinit.plugins.windows.userdata.UserDataPlugin

+ 0
- 37
Deployment/cloudbase-init/plugins/setagentconfig.py View File

@@ -1,37 +0,0 @@
1
-import codecs
2
-
3
-from cloudbaseinit.osutils.factory import *
4
-from cloudbaseinit.plugins.base import *
5
-from cloudbaseinit.openstack.common import log as logging
6
-
7
-opts = [
8
-    cfg.StrOpt('agent_config_file', default='C:\\Keero\\Agent\\WindowsAgent.exe.config', help='')
9
-]
10
-
11
-CONF = cfg.CONF
12
-CONF.register_opts(opts)
13
-
14
-LOG = logging.getLogger(__name__)
15
-
16
-
17
-class SetHostNamePlugin(BasePlugin):
18
-    def execute(self, service):
19
-        meta_data = service.get_meta_data('openstack')
20
-        if 'meta' not in meta_data:
21
-            LOG.debug("Section 'meta' not found in metadata")
22
-            return False
23
-
24
-        if 'agent_config_xml' not in meta_data['meta']:
25
-        	LOG.debug("Config for agent not found in metadata section")
26
-        	return False
27
-
28
-        try:
29
-	        configFile=codecs.open(CONF.agent_config_file, encoding='utf-8', mode='w+')
30
-	        configFile.write(meta_data['meta']['agent_config_xml'])
31
-	        configFile.close()
32
-	    except:
33
-	    	LOG.error("Unable to update agent file.")
34
-	    	return False
35
-
36
-	    return True
37
-

+ 0
- 20
Deployment/cloudbase-init/plugins/sethostname.py View File

@@ -1,20 +0,0 @@
1
-
2
-from cloudbaseinit.osutils.factory import *
3
-from cloudbaseinit.plugins.base import *
4
-from cloudbaseinit.openstack.common import log as logging
5
-
6
-LOG = logging.getLogger(__name__)
7
-
8
-
9
-class SetHostNamePlugin(BasePlugin):
10
-    def execute(self, service):
11
-        meta_data = service.get_meta_data('openstack')
12
-        if 'name' not in meta_data:
13
-            LOG.debug('Name not found in metadata')
14
-            return False
15
-
16
-        osutils = OSUtilsFactory().get_os_utils()
17
-
18
-        new_host_name = meta_data['name'].replace('.', '-')
19
-        return osutils.set_host_name(new_host_name)
20
-

+ 0
- 119
Deployment/cloudbase-init/plugins/userdata.py View File

@@ -1,119 +0,0 @@
1
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
2
-
3
-# Copyright 2012 Cloudbase Solutions Srl
4
-#
5
-#    Licensed under the Apache License, Version 2.0 (the "License"); you may
6
-#    not use this file except in compliance with the License. You may obtain
7
-#    a copy of the License at
8
-#
9
-#         http://www.apache.org/licenses/LICENSE-2.0
10
-#
11
-#    Unless required by applicable law or agreed to in writing, software
12
-#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
-#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
-#    License for the specific language governing permissions and limitations
15
-#    under the License.
16
-
17
-import re
18
-import tempfile
19
-import uuid
20
-import email
21
-import tempfile
22
-import os
23
-import errno
24
-
25
-from cloudbaseinit.openstack.common import cfg
26
-from cloudbaseinit.openstack.common import log as logging
27
-from cloudbaseinit.osutils.factory import *
28
-from cloudbaseinit.plugins.base import *
29
-
30
-LOG = logging.getLogger(__name__)
31
-
32
-opts = [
33
-    cfg.StrOpt('user_data_folder', default='cloud-data',
34
-        help='Specifies a folder to store multipart data files.'),
35
-    ]
36
-
37
-CONF = cfg.CONF
38
-CONF.register_opts(opts)
39
-
40
-class UserDataPlugin():
41
-    def __init__(self, cfg=CONF):
42
-        self.cfg = cfg
43
-        self.msg = None
44
-        return
45
-
46
-    def execute(self, service):
47
-        user_data = service.get_user_data('openstack')
48
-        if not user_data:
49
-            return False
50
-
51
-        LOG.debug('User data content:\n%s' % user_data)
52
-
53
-        if user_data.startswith('Content-Type: multipart'):
54
-            for part in self.parse_MIME(user_data):
55
-                self.process_part(part)
56
-        else:
57
-            self.handle(user_data)
58
-        return
59
-
60
-    def process_part(self, part):
61
-        if part.get_filename() == 'cfn-userdata':
62
-            self.handle(part.get_payload())
63
-        return
64
-
65
-    def parse_MIME(self, user_data):
66
-        folder = self.cfg.user_data_folder
67
-        self.create_folder(folder)
68
-
69
-        self.msg = email.message_from_string(user_data)
70
-        return self.msg.walk()
71
-
72
-
73
-    def create_folder(self, folder):
74
-        try:
75
-            os.mkdir(folder)
76
-        except os.OSError, e:
77
-            if e.errno != errno.EEXIST:
78
-                raise e
79
-        return
80
-
81
-    def handle(self, user_data):
82
-
83
-        osutils = OSUtilsFactory().get_os_utils()
84
-
85
-        target_path = os.path.join(tempfile.gettempdir(), str(uuid.uuid4()))
86
-        if re.search(r'^rem cmd\s', user_data, re.I):
87
-            target_path += '.cmd'
88
-            args = [target_path]
89
-            shell = True
90
-        elif re.search(r'^#!', user_data, re.I):
91
-            target_path += '.sh'
92
-            args = ['bash.exe', target_path]
93
-            shell = False
94
-        elif re.search(r'^#ps1\s', user_data, re.I):
95
-            target_path += '.ps1'
96
-            args = ['powershell.exe', '-ExecutionPolicy', 'RemoteSigned',
97
-                    '-NonInteractive', target_path]
98
-            shell = False
99
-        else:
100
-            # Unsupported
101
-            LOG.warning('Unsupported user_data format')
102
-            return False
103
-
104
-        try:
105
-            with open(target_path, 'wb') as f:
106
-                f.write(user_data)
107
-            (out, err, ret_val) = osutils.execute_process(args, shell)
108
-
109
-            LOG.info('User_data script ended with return code: %d' % ret_val)
110
-            LOG.debug('User_data stdout:\n%s' % out)
111
-            LOG.debug('User_data stderr:\n%s' % err)
112
-        except Exception, ex:
113
-            LOG.warning('An error occurred during user_data execution: \'%s\'' % ex)
114
-        finally:
115
-            if os.path.exists(target_path):
116
-                os.remove(target_path)
117
-
118
-        return False
119
-

+ 0
- 24
Deployment/cloudbase-init/userdata/Sample.ps1 View File

@@ -1,24 +0,0 @@
1
-Import-Module CoreFunctions
2
-
3
-$ModuleBase = "C:\Keero\Modules"
4
-
5
-
6
-$NewModule_Name = "ModuleName"
7
-$NewModule_Base64 = @'
8
-%BASE64_STRINGS%
9
-'@
10
-
11
-
12
-$AgentConfig_Path = "C:\Keero\Agent\WindowsAgent.exe.config"
13
-$AgentConfig_Base64 = @'
14
-%AGENT_CONFIG_BASE64%
15
-'@
16
-
17
-
18
-ConvertFrom-Base64String -Base64String $NewModule_Base64 -Path "$ModuleBase\$NewModule_Name.zip"
19
-Remove-Item -Path "$ModuleBase\$NewModule_Name" -Recurse -Force
20
-Expand-Zip -Path "$ModuleBase\$NewModule_Name.zip" -Destination "$ModuleBase\$NewModule_Name"
21
-
22
-
23
-Remove-Item -Path $AgentConfig_Path -Force
24
-ConvertFrom-Base64String -Base64String $NewModule_Base64 -Path $AgentConfig_Path

+ 0
- 51
Deployment/devstack-scripts/compute/devstack.localrc View File

@@ -1,51 +0,0 @@
1
-# Devstack's config file for COMPUTE intallation
2
-
3
-
4
-lab_id=102
5
-lab_password=swordfish
6
-lab_controller=172.18.124.100
7
-
8
-
9
-SERVICE_HOST=$lab_controller
10
-HOST_IP=172.18.124.${lab_id}
11
-MULTI_HOST=1
12
-
13
-
14
-FLAT_INTERFACE=eth1
15
-#PUBLIC_INTERFACE=eth0.261
16
-
17
-
18
-FIXED_RANGE=192.168.102.0/24
19
-FIXED_NETWORK_SIZE=254
20
-FLOATING_RANGE=172.18.124.228/27
21
-
22
-
23
-MYSQL_HOST=$lab_controller
24
-RABBIT_HOST=$lab_controller
25
-GLANCE_HOSTPORT=$lab_controller:9292
26
-KEYSTONE_AUTH_HOST=$lab_controller
27
-KEYSTONE_SERVICE_HOST=$lab_controller
28
-
29
-
30
-VNCSERVER_LISTEN=$HOST_IP
31
-VNCSERVER_PROXYCLIENT_ADDRESS=$HOST_IP
32
-
33