-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestdeploy.ps1
92 lines (85 loc) · 2.72 KB
/
testdeploy.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
param (
[parameter (
mandatory = $false
)
]
[string]$Computer_Name = "172.26.52.60",
[parameter (
mandatory = $false
)
]
[string]$User_Name = "INTIMETEC\Administrator",
[parameter (
mandatory = $false
)
]
[string]$Website_Name = "deploytest",
[parameter (
mandatory = $true
)
]
[int]$Port_Number
)
function Manage-Remote {
#####################################################################################################
<#CREATING & ENTERING PS SESSION#>
try{
$password = ConvertTo-SecureString 'BlueBug0811' -AsPlainText -Force
$credential = New-Object System.Management.Automation.PSCredential ('INTIMETEC\Administrator', $password)
$session = New-PSSession -ComputerName "172.27.125.150" -Credential $credential -ErrorAction stop
write-host "Created Session"
}
catch{
write-host "Cannot Create Session"
}
Invoke-Command -Session $Session -ScriptBlock {
<#ENABLING IIS SERVER#>
param($Web_Name)
if($((Get-WindowsFeature -Name web-server).installed)) {
Write-Host "WEB MANAGEMENT SERVICE ALREADY INSTALLED"
}
else {
try {
add-windowsfeature -name web-server -includemanagementtools
Write-Host "SUCCESSFULLY ENABLED IISServer"
}
catch {
Write-Host "CANNOT ENABLE IIS SERVER"
Break;
}
}
<#ENABLING WEB MANAGEMENT SERVICE#>
if($((Get-WindowsFeature -Name Web-Mgmt-Service).installed)) {
Write-Host "WEB MANAGEMENT SERVICE ALREADY INSTALLED"
}
else {
try {
add-windowsfeature -name Web-Mgmt-Service
Write-Host "SUCCESSFULLY INSTALLED WEB MANAGEMENT SERVICE"
}
catch {
Write-Host "CANNOT INSTALL WEB MANAGEMENT SERVICE"
Break;
}
}
<#CREATING DIRECTORY FOR WEBSITE#>
try {
New-Item -Path "C:\" -Name "$Web_Name" -ItemType Directory
Write-Host "DIRECTORY CREATED FOR WEBSITE"
}
catch {
Write-Host "CANNOT CREATE A DIRECTORY FOR WEBSITE"
Break;
}
} -Args $Website_Name
<#COPYING FILES FOR WEBSITE#>
try {
Copy-Item -path "WebContent\netcoreapp3.1.zip" -Destination "C:\$Website_Name" -ToSession $Session
Write-Host "FILES COPIED FOR WEBSITE"
}
catch {
Write-Host "CANNOT COPY FILES FOR WEBSITE"
Break;
}
}
Manage-Remote