-
Notifications
You must be signed in to change notification settings - Fork 7
/
ZZZ-Testing.ps1
136 lines (77 loc) · 2.17 KB
/
ZZZ-Testing.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
Get-AzureRmResourceGroup | Select-Object ResourceGroupName,Location
Get-AzureRmVirtualNetwork | Select-Object Name,ResourceGroupName,Location
Get-AzureRmNetworkSecurityGroup | Select-Object Name,ResourceGroupName,Location
# connect to azure
Add-AzureRmAccount
# other cmd
Login-AzureRmAccount
Get-AzureRmLocation
Connect-AzureRmAccount
$hasPublicIp = $true
if($hasPublicIp)
{
"y"
}
else
{
"N"
}
$natRuleName = "dsd"
$fd = "$($natRuleName)3"
$fd
$cred = Get-Credential -Message "Enter a username and password for the virtual machine."
$username = "aashish"
$password = ConvertTo-SecureString -String "Password@1234" -AsPlainText -Force
$cred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $username, $password
$StorageAccount = ($RgPrefix + "Storage").ToLower()
for ($i=1; $i -le 3; $i++)
{
New-AzureRmNetworkInterface `
-ResourceGroupName "myResourceGroupLoadBalancer" `
-Name myVM$i `
-Location "EastUS" `
-Subnet $vnet.Subnets[0] `
-LoadBalancerBackendAddressPool $lb.BackendAddressPools[0]
}
function Get-Something
{
[CmdletBinding()]
param
(
[Parameter(Mandatory)]
[string]$Thing1,
[Parameter(Mandatory)]
[string]$Thing2,
[Parameter()]
[string]$Thing3 = 'adefaultvalue'
)
Set-Something @PSBoundParameters
}
Get-Something –Thing1 'hello' –Thing2 'world'
function GetResourceName ($name, $suffix = "", $joinChar = "-")
{
if($suffix)
{
return $name;
}
return "${name}${joinChar}${suffix}"
}
GetResourceName Name "Ashish" Suffix "-rg"
$GetWmiObjectParams = @{
Class = "Win32_LogicalDisk"
Filter = "DriveType=3"
ComputerName = "SERVER2"
}
Get-WmiObject @GetWmiObjectParams.
$publicIp = Get-AzureRmPublicIpAddress -Name "fffffff" -ResourceGroupName "aabbccdd12-rg" -ErrorVariable isIPExist -ErrorAction SilentlyContinue `
if($isIPExist )
{
"yes"
}
else
{
"no"
}
Write-Verbose
Write-Verbose "Verbose output"
"Regular output"