powershell
28 TopicsPowerShell ile Azure Baglanma (tr-TR)
PowerShell kullandığınız işletim sistemleriniz üzerinden Azure modullerini yüklemenizi gerçekleştirip Azure portalınıza bağlanıp Azure Cloud Shell konforunda işlemlerinizi gerçekleştirebilirsiniz. Azure PowerShell modülünün yüklenemsi için aşağıdaki komutu kopyala yapıştır yöntemi ile çalıştırabilirsiniz. if (Get-Module -Name AzureRM -ListAvailable) { Write-Warning -Message 'Az module not installed. Having both the AzureRM and Az modules installed at the same time is not supported.' } else { Install-Module -Name Az -AllowClobber -Scope CurrentUser } Modül yükleme işlemi sırasında gelen sorulara önce Y sonra A şeklinde yanıtlayarak devam edebilirsiniz. Komut örnek PowerShell çıktısı aşağıdaki gibidir. PS C:\Users\Administrator> if (Get-Module -Name AzureRM -ListAvailable) { Write-Warning -Message 'Az module not insta lled. Having both the AzureRM and Az modules installed at the same time is not supported.'} else { Install-Module -Na me Az -AllowClobber -Scope CurrentUser} NuGet provider is required to continue PowerShellGet requires NuGet provider version '2.8.5.201' or newer to interact with NuGet-based repositories. The NuGet provider must be available in 'C:\Program Files\PackageManagement\ProviderAssemblies' or 'C:\Users\Administrator\AppData\Local\PackageManagement\ProviderAssemblies'. You can also install the NuGet provider by running 'Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force'. Do you want PowerShellGet to install and import the NuGet provider now? [Y] Yes [N] No [S] Suspend [?] Help (default is "Y"): y Untrusted repository You are installing the modules from an untrusted repository. If you trust this repository, change its InstallationPolicy value by running the Set-PSRepository cmdlet. Are you sure you want to install the modules from 'PSGallery'? [Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "N"): a PS C:\Users\Administrator> PowerShell ile Azure bağlantısı icin Connect-AzAccount komutunu kullanrak işlemi gerçekleştirebilirsiniz. Connect-AzAccount Login penceresinden giriş yaparak işlemi sürdürünüz. Bağlantı süreciniz tamamlandığında aşağıdaki şekilde örnek komut çıktısını görebilirsiniz. PS C:\Users\Administrator> Connect-AzAccount Account SubscriptionName TenantId Environment ------- ---------------- -------- ----------- emreozanmemis@hotmail.com Microsoft Azure Sponsorship 5**********************1 AzureCloud PS C:\Users\Administrator> İşte şu an zamandan tasaruf etmenin anahtarı ile Azure Portalına giriş yaptınız. Azure işlem süreçlerinizi standartlaştırmak ve kurulum yapılandırma süreçlerinizi hızlandırmak için mevcut iş süreçlerinin PowerShell komutlarını hazırlayarak kendinize komut kütüphanesi oluşturmanızı öneririm. PowerShell ile Azure portalında güzel zaman geçirmeniz dileğiyle bir sonraki Azure PowerShell makalesinde görüşmek üzere...1.2KViews6likes0CommentsAzure Cloud Shell ile Windows Server 2019 VM olusturma (tr-TR)
Zamanın ötesinde yaşayan en önemlisi zamanın kıymetini bilen sistem yöneticilerinin yeni vazgeçilmezi olan Azure Cloud Shell sayesinde dakikalar içerisinde sadece bir kaç satır komut yada script ile en önemlisi aynı standartda sanal sunucu kurulumları gerçekleştirebilirsiniz. Azure Cloud Shell (PowerShell) ile derlemiş olduğum komutlar sayesinde önce kaynak grubu oluşturup akabinde sanal networkunuzu yapılandırabilirsiniz. Sanal sunucunzun temeli olacak kaynak grubu ve sanal networkunuz oldukça önemli bir kurulumdur. Doğru kurgulanan sanal networkunuz sayesinde ileride eklemek istediğiniz diğer Azure featureları için kolaylık sağlayacaktır. New-AzResourceGroup -Name PSAzureRG -Location westus $gatewaysubnet = New-AzVirtualNetworkSubnetConfig -Name GatewaySubnet -AddressPrefix "192.172.101.0/27" $virtualNetwork = New-AzVirtualNetwork -Name AzureBCVnet -ResourceGroupName PSAzureBootCampRG -Location westus -AddressPrefix "192.172.101.0/24" -Subnet $gatewaysubnet Add-AzVirtualNetworkSubnetConfig -Name AzureFirewallSubnet -VirtualNetwork $virtualNetwork -AddressPrefix "192.172.101.32/27" Add-AzVirtualNetworkSubnetConfig -Name DMZSubnet -VirtualNetwork $virtualNetwork -AddressPrefix "192.172.101.96/27" $virtualNetwork | Set-AzVirtualNetwork Oluşturdunuz sanal networkunuz sonrasu sanal sunucunuz için ihtiyacınız olacak public IP ve sunucunuzun diğer değişken detaylarını ikinci bölümde hazırladığım komutlar ile tamamlayabilirsiniz. #create VM $publicipvm = New-AzPublicIpAddress -ResourceGroupName "PSAzureRG" -name "VMIP" -location "westus" -AllocationMethod Static -Sku Standard $resourceGroup = "PSAzureRG" $location = "westus" $vmName = "ACS-w2019-vm" $cred = Get-Credential -Message "Enter a username and password for the virtual machine." New-AzResourceGroup -Name $resourceGroup -Location $location New-AzVM -ResourceGroupName $resourceGroup -Name $vmName -Location $location -ImageName "Win2019Datacenter" -Size "Standard_D2_v3" -VirtualNetworkName "AzureBCVnet" -SubnetName "DMZSubnet" -PublicIpAddressName $publicipvm -Credential $cred -OpenPorts 3389 İlk bölümde oluşturduğunuz kaynak grubunda ve sanal networkunda olan sanal sunucunuz için işletim sistemi opsiyonu olarak Windows Server 2019 Datacenter ve boyut olarak da D2_v3 seçiyorum. Oluşturduğum sanal network ve public IP yi sunucuma tanımlayıp 3389 portundan sunucuma RDP ile erişim sağlayıp işlemlerimi gerçekleştirmek için port izinimi veriyorum. İşte hepsi bu kadar komutu çalıştırıyorum ve 3-4 dakika içinde sanal sunucum hazır.2.3KViews5likes0CommentsPowershell Script to remove all Blobs from Storage account
With large number of Blobs in Storage Account, the manual cleanup from the Portal is more complicated and time consuming, as it's per set of 10'000. This script is simple and and can be executed in background to clean all items from a defined Blob Container. You have to specify the Storage Account connection string and the blob container name. [string]$myConnectionString = "DefaultEndpointsProtocol=https;AccountName=YourStorageAccountName;AccountKey=YourKeyFromStorageAccountConnectionString;EndpointSuffix=core.windows.net" [string]$ContainerName = "YourBlobContainerName" [int]$blobCountAfter = 0 [int]$blobCountBefore = 0 $context = New-AzStorageContext -ConnectionString $myConnectionString $blobCountBefore = (Get-AzStorageBlob -Container $ContainerName -Context $context).Count Write-Host "Total number of blobs in the container Before deletion: $blobCount" -ForegroundColor Yellow Get-AzStorageBlob -Container $ContainerName -Context $context | ForEach-Object { $_ | Remove-AzureStorageBlob # or: Remove-AzureStorageBlob -ICloudBlob $_.ICloudBlob -Context $ctx } $blobCountAfter = (Get-AzStorageBlob -Container $ContainerName -Context $context).Count Write-Host "Total number of blobs in the container After deletion : $blobCount" -ForegroundColor Green It was used for large blob storage container with more than 5 millions of blob items. Sources: https://learn.microsoft.com/en-us/powershell/module/az.storage/new-azstoragecontext?view=azps-13.0.0#examples https://learn.microsoft.com/en-us/answers/questions/1637785/what-is-the-easiest-way-to-find-the-total-number-o https://stackoverflow.com/questions/57119087/powershell-remove-all-blobs-in-a-container Fab199Views1like1CommentGet AzADGroupMembers from nested groups
Hi, I'm trying to get all members of a group (including nested groups members) to add to a teams private channel. We have a script to add members of a group to a private channel, but it will not add nested groups members. $members = Get-AzADGroupMember -ObjectId 'source_groupID_here' | select mail $tal = 0 foreach ($member in $members) { $User = $member.mail Add-TeamChannelUser -GroupId 'teams_groupID_here' -DisplayName 'Private_channel_name' -user $User $tal += 1 } $tal Is there a way to add those who are members of the nested groups without having to add each nested group individually?17KViews1like3Comments