Neximus

Azure Suli jegyzetek

Oct 13th, 2025 (edited)
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PowerShell 7.46 KB | Source Code | 0 0
  1. # 🔐 Azure bejelentkezĂ©s Ă©s elƑkĂ©szĂ­tĂ©s
  2.  
  3. Connect-AzAccount                      # BejelentkezĂ©s az Azure fiĂłkba
  4. Get-AzSubscription                     # ElĂ©rhetƑ elƑfizetĂ©sek lekĂ©rdezĂ©se
  5. Set-AzContext -SubscriptionName "Azure subscription 1"  # AktĂ­v elƑfizetĂ©s kivĂĄlasztĂĄsa
  6. Get-AzResourceGroup                    # MeglĂ©vƑ Resource Group-ok listĂĄzĂĄsa
  7.  
  8.  
  9. # đŸ§± Resource Group lĂ©trehozĂĄsa Ă©s törlĂ©se
  10.  
  11. New-AzResourceGroup -Name "SZOMBAT" -Location "northeurope"   # Új RG lĂ©trehozĂĄsa
  12. Remove-AzResourceGroup -Name "SZOMBAT" -Force                 # RG törlĂ©se megerƑsĂ­tĂ©s nĂ©lkĂŒl
  13.  
  14.  
  15. # 🌐 VirtuĂĄlis hĂĄlĂłzat (VNet) lĂ©trehozĂĄsa + Subnet hozzĂĄadĂĄsa
  16.  
  17. $vnet = New-AzVirtualNetwork -Name "SZOMBAT-NET" `             # VNet lĂ©trehozĂĄsa
  18.   -ResourceGroupName "SZOMBAT" `
  19.   -Location "northeurope" `
  20.   -AddressPrefix "10.0.0.0/16"
  21.  
  22. Add-AzVirtualNetworkSubnetConfig -Name "SZOMBAT-NET-SUB1" `    # Subnet lĂ©trehozĂĄsa a VNet-ben
  23.   -AddressPrefix "10.0.1.0/24" `
  24.   -VirtualNetwork $vnet
  25.  
  26. $vnet | Set-AzVirtualNetwork            # MentĂ©s / frissĂ­tĂ©s (nĂ©lkĂŒle nem jön lĂ©tre a subnet)
  27.  
  28.  
  29. # 🌍 MĂĄsik pĂ©lda: Resource Group, VNet, Subnet manuĂĄlis paramĂ©terezĂ©ssel
  30.  
  31. New-AzResourceGroup -Name proba-rg -Location northeurope       # RG lĂ©trehozĂĄsa
  32. Get-AzResourceGroup -Name proba-rg                             # EllenƑrzĂ©s
  33.  
  34. # VĂĄltozĂłk
  35. $ResourceGroup="Proba-Rg"
  36. $Location="northeurope"
  37. $VnetName="Proba-Net"
  38. $AddressPrefix="10.1.0.0/16"
  39. $SubnetName="Alap-Subnet"
  40. $SubnetPrefix="10.1.0.0/24"
  41.  
  42. # Subnet-konfiguråció létrehozåsa
  43. $SubnetConfig=New-AzVirtualNetworkSubnetConfig -Name $SubnetName `
  44.   -AddressPrefix $SubnetPrefix
  45.  
  46. # VirtuĂĄlis hĂĄlĂłzat lĂ©trehozĂĄsa a subnettel egyĂŒtt
  47. New-AzVirtualNetwork -Name $VnetName `
  48.   -ResourceGroupName $ResourceGroup `
  49.   -Location $Location `
  50.   -AddressPrefix $AddressPrefix `
  51.   -Subnet $SubnetConfig
  52.  
  53. # Új subnet hozzĂĄadĂĄsa meglĂ©vƑ VNet-hez
  54. $vnet = Get-AzVirtualNetwork -Name $VnetName -ResourceGroupName $ResourceGroup
  55. Add-AzVirtualNetworkSubnetConfig -Name "Munka-Subnet" -AddressPrefix "10.1.1.0/24" -VirtualNetwork $vnet
  56. $vnet | Set-AzVirtualNetwork          # MentĂ©s / frissĂ­tĂ©s
  57. $vnet = Get-AzVirtualNetwork -Name $VnetName -ResourceGroupName $ResourceGroup  # ← FrissĂ­tĂ©s!
  58. $vnet.Subnets | Select-Object Name, AddressPrefix
  59.  
  60. # Subnet törlése
  61. Remove-AzVirtualNetworkSubnetConfig -Name "Munka-Subnet" -VirtualNetwork $vnet
  62. $vnet | Set-AzVirtualNetwork           # IsmĂ©t mentĂ©s!
  63. $vnet = Get-AzVirtualNetwork -Name $VnetName -ResourceGroupName $ResourceGroup  # ← FrissĂ­tĂ©s!
  64.  
  65. # đŸ’» Alap VM lĂ©trehozĂĄsa (egysoros parancs)
  66.  
  67. New-AzVM -ResourceGroupName "Proba-Rg" `
  68.   -Location "northeurope" `
  69.   -Name 'UjabbVM' `
  70.   -VirtualNetworkName 'Proba-Net' `
  71.   -SubnetName 'Alap-Subnet' `
  72.   -Image 'MicrosoftWindowsServer:WindowsServer:2022-datacenter-azure-edition:latest' `
  73.   -SecurityGroupName 'Proba-NSG' `
  74.   -PublicIpAddressName 'SajatIP' `
  75.   -OpenPorts 3389
  76.  
  77. Remove-AzVM -Name 'UjabbVM' -ResourceGroupName "Proba-Rg"      # VM törlĂ©se
  78.  
  79.  
  80. # ⚙ HaladĂł VM lĂ©trehozĂĄs rĂ©szletes komponensekkel
  81.  
  82. # AlapvĂĄltozĂłk
  83. $ResourceGroup = "Proba-Rg"
  84. $Location = "northeurope"
  85. $VmName = "ProbaVM"
  86. $VnetName = "Proba-Net"
  87. $SubnetName = "Alap-Subnet"
  88. $AddressPrefix = "10.1.0.0/16"
  89. $SubnetPrefix = "10.1.1.0/24"
  90.  
  91. # Resource Group létrehozåsa
  92. New-AzResourceGroup -Name $ResourceGroup -Location $Location
  93.  
  94. # VNet létrehozåsa
  95. $vnet = New-AzVirtualNetwork -ResourceGroupName $ResourceGroup `
  96.     -Location $Location `
  97.     -Name $VnetName `
  98.     -AddressPrefix $AddressPrefix
  99.  
  100. # Subnet hozzĂĄadĂĄsa
  101. Add-AzVirtualNetworkSubnetConfig -Name $SubnetName `
  102.     -AddressPrefix $SubnetPrefix `
  103.     -VirtualNetwork $vnet
  104.  
  105. # VNet mentése
  106. $vnet | Set-AzVirtualNetwork
  107.  
  108. # Frissített VNet és Subnet lekérése
  109. $vnet = Get-AzVirtualNetwork -Name $VnetName -ResourceGroupName $ResourceGroup
  110. $subnet = Get-AzVirtualNetworkSubnetConfig -Name $SubnetName -VirtualNetwork $vnet
  111.  
  112. # Public IP cím létrehozåsa
  113. $PublicIP = New-AzPublicIpAddress -Name "$VmName-pip" `
  114.     -ResourceGroupName $ResourceGroup `
  115.     -Location $Location `
  116.     -AllocationMethod Static `
  117.     -Sku Standard
  118.  
  119. # NSG + RDP szabĂĄly
  120. $RDP = New-AzNetworkSecurityRuleConfig -Name "RDP-Allow" `
  121.     -Protocol Tcp `
  122.     -Direction Inbound `
  123.     -Priority 1001 `
  124.     -SourceAddressPrefix * `
  125.     -SourcePortRange * `
  126.     -DestinationAddressPrefix * `
  127.     -DestinationPortRange 3389 `
  128.     -Access Allow
  129.  
  130. $nsg = New-AzNetworkSecurityGroup -ResourceGroupName $ResourceGroup `
  131.     -Location $Location `
  132.     -Name "$VmName-nsg" `
  133.     -SecurityRules $RDP
  134.  
  135. # NIC IP Config lĂ©trehozĂĄsa - JAVÍTVA
  136. $IPConfig = New-AzNetworkInterfaceIpConfig -Name "$VmName-ipconfig" `
  137.     -SubnetId $subnet.Id `
  138.     -PublicIpAddressId $PublicIP.Id `
  139.     -Primary
  140.  
  141. # NIC létrehozåsa
  142. $nic = New-AzNetworkInterface -Name "$VmName-nic" `
  143.     -ResourceGroupName $ResourceGroup `
  144.     -Location $Location `
  145.     -IpConfiguration $IPConfig `
  146.     -NetworkSecurityGroupId $nsg.Id
  147.  
  148. # Hitelesítés
  149. $cred = New-Object System.Management.Automation.PSCredential ("azureadmin", (ConvertTo-SecureString "Password2025!" -AsPlainText -Force))
  150.  
  151. # VM konfigurĂĄciĂł
  152. $vmconfig = New-AzVMConfig -VMName $VmName -VMSize "Standard_D2s_v3" `
  153.   | Set-AzVMOperatingSystem -Windows -ComputerName $VmName -Credential $cred -ProvisionVMAgent -EnableAutoUpdate `
  154.   | Set-AzVMSourceImage -PublisherName "MicrosoftWindowsServer" `
  155.     -Offer "WindowsServer" -Skus "2022-datacenter-azure-edition" -Version "latest" `
  156.   | Add-AzVMNetworkInterface -Id $nic.Id
  157.  
  158. # VM létrehozåsa
  159. New-AzVM -ResourceGroupName $ResourceGroup -Location $Location -VM $vmconfig
  160.  
  161.  
  162. # ------------
  163. # Felhasznalok
  164. # ------------
  165.  
  166. Connect-AzureAD                              
  167. # 1. MeglĂ©vƑ felhasznĂĄlĂłk Ă©s csoportok lekĂ©rdezĂ©se
  168. Get-AzADUser
  169. Get-AzADGroup
  170.  
  171. # 2. ÚJ FELHASZNÁLÓ lĂ©trehozĂĄsa (CSAK az Ășj verziĂł!)
  172. New-AzADUser -DisplayName "Gipsz Jakab" `
  173.   -UserPrincipalName "[email protected]" `
  174.   -Password (ConvertTo-SecureString "Jelszo2025!" -AsPlainText -Force) `
  175.   -AccountEnabled $true `
  176.   -MailNickname "Gipsz"
  177.  
  178. # 3. ÚJ CSOPORT lĂ©trehozĂĄsa
  179. New-AzADGroup -DisplayName "Dolgozok" -MailNickname "Dolgozok"
  180.  
  181. # 4. FELHASZNÁLÓ HOZZÁADÁSA csoporthoz
  182. # MĂłdszer 1: UserPrincipalName alapjĂĄn
  183. Add-AzADGroupMember -MemberUserPrincipalName "[email protected]" -TargetGroupDisplayName "Dolgozok"
  184.  
  185. # MĂłdszer 2: ObjectId alapjĂĄn (megbĂ­zhatĂłbb)
  186. $user = Get-AzADUser -UserPrincipalName "[email protected]"
  187. $group = Get-AzADGroup -DisplayName "Dolgozok"
  188. Add-AzADGroupMember -MemberObjectId $user.Id -TargetGroupObjectId $group.Id
  189.  
  190. # 5. FELHASZNÁLÓ lekĂ©rdezĂ©se
  191. Get-AzADUser -UserPrincipalName "[email protected]"
  192.  
  193. # 6. FELHASZNÁLÓ TÖRLÉSE
  194. Remove-AzADUser -UserPrincipalName "[email protected]"
  195.  
  196. # 7. FELHASZNÁLÓ MÓDOSÍTÁSA
  197. # FIGYELEM: Az ObjectId-t le kell kĂ©rdezned elƑtte!
  198. $user = Get-AzADUser -UserPrincipalName "[email protected]"
  199. Update-AzADUser -ObjectId $user.Id -DisplayName "Ez az uj display name"
  200.  
  201. # 8. CSOPORT TAGOK lekérdezése
  202. $group = Get-AzADGroup -DisplayName "Dolgozok"
  203. Get-AzADGroupMember -GroupObjectId $group.Id
  204.  
  205. # 9. FELHASZNÁLÓ ELTÁVOLÍTÁSA csoportból
  206. $user = Get-AzADUser -DisplayName "Gipsz Jakab"
  207. $group = Get-AzADGroup -DisplayName "Dolgozok"
  208. Remove-AzADGroupMember -MemberObjectId $user.Id -GroupObjectId $group.Id
Advertisement
Add Comment
Please, Sign In to add comment