powershell
335 TopicsPowerShell ile Exchange 2019 kurulumu ve yapılandırması (tr-TR)
Microsoft'un en değer verdiği servislerinden biri olan Exchange hizmeti her geçen yıl yenilenyor ve güçlenerek servis edilmeye devam ediyor. Cloud ortamının yanı sıra On-Primeses ortamlarında vazgeçilmezi olan Exchange ürün ailesinin son sürümü Exchange 2019 bugün on-primeses ortamda Powershell ile kurulumunu gerçekleştireceğim. Exchange kurması ve yapılandırması biraz zahmetli bir servisdir bu sebeple kurulumu sizler için biraz dah basit bir hale getirerek web sayfalarında gezinip exchnage yüklemesi için gereken özelikleri aramanıza gerek yok. İlk olarka kurulum için gerekli olan Windows Server roles and features yükleyerek başlıyoruz. Exchange için Microsoft Windows Server roles and features yükleyici komutu Install-WindowsFeature NET-Framework-45-Features, RPC-over-HTTP-proxy, RSAT-Clustering, RSAT-Clustering-CmdInterface, RSAT-Clustering-Mgmt, RSAT-Clustering-PowerShell, Web-Mgmt-Console, WAS-Process-Model, Web-Asp-Net45, Web-Basic-Auth, Web-Client-Auth, Web-Digest-Auth, Web-Dir-Browsing, Web-Dyn-Compression, Web-Http-Errors, Web-Http-Logging, Web-Http-Redirect, Web-Http-Tracing, Web-ISAPI-Ext, Web-ISAPI-Filter, Web-Lgcy-Mgmt-Console, Web-Metabase, Web-Mgmt-Console, Web-Mgmt-Service, Web-Net-Ext45, Web-Request-Monitor, Web-Server, Web-Stat-Compression, Web-Static-Content, Web-Windows-Auth, Web-WMI, Windows-Identity-Foundation, RSAT-ADDS Exchange için gerekli olan iki harici uygulamayıda internetten PowerShell ile indirip yüklüyoruz. Windows server için Microsoft .NET Framework 4.8 çevrimdışı yükleyici komutu $WebClient = New-Object System.Net.WebClient $WebClient.DownloadFile("https://go.microsoft.com/fwlink/?linkid=2088631","C:\dotnet.exe") Windows server için Microsoft Visual C++ Redistributable for Visual Studio 2012 Update 4 yükleyici komutu $WebClient = New-Object System.Net.WebClient $WebClient.DownloadFile("https://www.microsoft.com/en-us/download/confirmation.aspx?id=30679&6B49FDFB-8E5B-4B07-BC31-15695C5A2143=1","C:\VSU_4.exe") Yüklemek için C:\ dizinine gelip ilgili uygulamaların yükleme paketlerini çalıştırıyoruz. C:\dotnet.exe C:\VSU_4.exe Exchange kurulumu için Wİndows Server işletim sistemimiz hazırdır. PowerShell de ISO nuzu mount ettiğiniz dizine gidiniz ve aşağıdaki komutları sırası ile çalıştırınız. Setup.exe /IAcceptExchangeServerLicenseTerms /PrepareSchema Setup.exe /IAcceptExchangeServerLicenseTerms /PrepareAD /OrganizationName: <Domain adi> Setup.exe /IAcceptExchangeServerLicenseTerms /PrepareAllDomains Setup.exe /mode:Install /role:Mailbox /IAcceptExchangeServerLicenseTerms ISO dizininde çalıştırabilceğiniz diğer komutlar NOT: Setup.exe [/Mode:] [/IAcceptExchangeServerLicenseTerms] [/Role:] [/InstallWindowsComponents] [/OrganizationName:] [/TargetDir:] [/SourceDir:] [/UpdatesDir:] [/DomainController:] [/DisableAMFiltering] [/AnswerFile:] [/DoNotStartTransport] [/EnableErrorReporting] [/CustomerFeedbackEnabled:] [/AddUmLanguagePack:] [/RemoveUmLanguagePack:] [/NewProvisionedServer:] [/RemoveProvisionedServer:] [/MdbName:] [/DbFilePath:] [/LogFolderPath:] [/ActiveDirectorySplitPermissions:] [/TenantOrganizationConfig:] Kurulum sonrası virtual directory yapılandırması için hostnamenizi yazıp scripti çalıştırınız. $hostname = "" Set-EcpVirtualDirectory "$HostName\ECP (Default Web Site)" -InternalUrl ((Get-EcpVirtualDirectory "$HostName\ECP (Default Web Site)").ExternalUrl) Set-WebServicesVirtualDirectory "$HostName\EWS (Default Web Site)" -InternalUrl ((Get-WebServicesVirtualDirectory "$HostName\EWS (Default Web Site)").ExternalUrl) Set-ActiveSyncVirtualDirectory "$HostName\Microsoft-Server-ActiveSync (Default Web Site)" -InternalUrl ((Get-ActiveSyncVirtualDirectory "$HostName\Microsoft-Server-ActiveSync (Default Web Site)").ExternalUrl) Set-OabVirtualDirectory "$HostName\OAB (Default Web Site)" -InternalUrl ((Get-OabVirtualDirectory "$HostName\OAB (Default Web Site)").ExternalUrl) Set-OwaVirtualDirectory "$HostName\OWA (Default Web Site)" -InternalUrl ((Get-OwaVirtualDirectory "$HostName\OWA (Default Web Site)").ExternalUrl) Set-PowerShellVirtualDirectory "$HostName\PowerShell (Default Web Site)" -InternalUrl ((Get-PowerShellVirtualDirectory "$HostName\PowerShell (Default Web Site)").ExternalUrl) Son olarak send ve recive connectorlerinizi yapılandırınız. Set-ReceiveConnector Set-SendConnector Önemli not domaininiz için DNS A kayıtları MX ve SPF kayıtlarınız için ilgili yönlendirmeleri yaptıktan sonra Exchange ile mail alım ve gönderim işlemine başlayabilirsiniz.1.6KViews5likes0CommentsPowerShell ile Invoke-WebRequest işlemleri (tr-TR)
PowerShell ile Webde surf yapmaya hazır mısınız? PowerShell ile browser tadında bir surf keyfi için tanımanız gereken komut "Invoke-WebRequest" ta kendisidir. Invoke-WebRequest öncesi size basit bir PowerShell script ile dosya nasıl download edebilirsiniz göstermek isterim. $WebClient = New-Object System.Net.WebClient $WebClient.DownloadFile("http://<download linkinizi yazınız>","C:\dosya isminiz.formatı") Örneğin windows admin center indirmek istiyorsunuz. Link ve indirmek istediğiniz dizini belirterek download işlemini gerçekleştirebilirsiniz. Biz bu örneğimizde Windows Admin Center download linkini yazıyoruz ve C:\ dizininde oluşmasını istiyoruz. $WebClient = New-Object System.Net.WebClient $WebClient.DownloadFile("http://aka.ms/WACDownload","C:\wac.msi") Scrtipmizi çalıştırdıktan sonra mevcut uygulama çıktısı aşağıdaki gibidir. Windows PowerShell Copyright (C) Microsoft Corporation. All rights reserved. PS C:\Users\Administrator> $WebClient = New-Object System.Net.WebClient PS C:\Users\Administrator> $WebClient.DownloadFile("http://aka.ms/WACDownload","C:\wac.msi") PS C:\Users\Administrator> cd.. PS C:\Users> cd.. PS C:\> dir Directory: C:\ Mode LastWriteTime Length Name ---- ------------- ------ ---- d----- 15.09.2018 10:19 PerfLogs d-r--- 16.05.2020 22:10 Program Files d----- 18.05.2020 15:32 Program Files (x86) d-r--- 9.05.2020 14:57 Users d----- 18.05.2020 11:30 Windows -a---- 18.05.2020 15:49 62980096 wac.msi PS C:\> Aynı süreci Invoke-WebRequest komutu ile gerçekleştirelim. daha basit şekilde işlemi halledelim yine bir önceki örneğimizde olduğu gibi indirme linkini ve indireceğimiz yeri belirliyoruz. Invoke-WebRequest -Uri "<download linkini giriniz>" -OutFile "C:\dosya adiniz.formati" Örnek Komutumuz ile MS SQL 2017 downlaod edelim. İndirme linkini ve indirmek istediğim dizini belirtiryorum. Invoke-WebRequest -Uri "https://go.microsoft.com/fwlink/?linkid=853017" -OutFile "C:\sql2017.exe" Uygulama çıktısı aşağıdaki gibidir. Windows PowerShell Copyright (C) Microsoft Corporation. All rights reserved. PS C:\Users\Administrator> Invoke-WebRequest -Uri "https://go.microsoft.com/fwlink/?linkid=853017" -OutFile "C:\sql2017. exe" PS C:\Users\Administrator> cd.. PS C:\Users> cd.. PS C:\> dir Directory: C:\ Mode LastWriteTime Length Name ---- ------------- ------ ---- d----- 15.09.2018 10:19 PerfLogs d-r--- 16.05.2020 22:10 Program Files d----- 18.05.2020 15:32 Program Files (x86) d-r--- 9.05.2020 14:57 Users d----- 18.05.2020 11:30 Windows -a---- 18.05.2020 15:52 5325976 sql2017.exe -a---- 18.05.2020 15:49 62980096 wac.msi PS C:\> Invoke-WebRequest ile bir web sitenin içeriğini txt formatında dowload edebilirsiniz. Bu sefer biraz daha karmaşık bir komut hazırlıyoruz. Pipline kullanarak bir objenin içeriğini Invoke-WebRequest ile çağırıp daha sonra bu içeriği txt olarak çıktısını alıyoruz. Invoke-WebRequest "web adresi" | Select-Object -ExpandProperty Content | Out-File "C:\dosya ismi.txt" Örneğin emreozanmemis.com web sitesi için bu süreci uygulayalım. Invoke-WebRequest "http://emreozanmemis.com" | Select-Object -ExpandProperty Content | Out-Fi le "C:\emreozanmemis.txt" Uygulama çıktısı aşağıdaki gibidir. Windows PowerShell Copyright (C) Microsoft Corporation. All rights reserved. PS C:\Users\Administrator> Invoke-WebRequest "http://emreozanmemis.com" | Select-Object -ExpandProperty Content | Out-Fi le "C:\emreozanmemis.txt" PS C:\Users\Administrator> cd.. PS C:\Users> cd.. PS C:\> dir Directory: C:\ Mode LastWriteTime Length Name ---- ------------- ------ ---- d----- 15.09.2018 10:19 PerfLogs d-r--- 16.05.2020 22:10 Program Files d----- 18.05.2020 15:32 Program Files (x86) d-r--- 9.05.2020 14:57 Users d----- 18.05.2020 11:30 Windows -a---- 18.05.2020 15:56 101964 emreozanmemis.txt -a---- 18.05.2020 15:52 5325976 sql2017.exe -a---- 18.05.2020 15:49 62980096 wac.msi PS C:\> Bu içeriği hiç indirmeden görüntülemek isterseniz de aşağıdaki komut işinizi fazlasıyla görecektir. Invoke-WebRequest "http://www.emreozanmemis.com" -OutFile "file" -PassThru | Select-Object -ExpandProperty Content Uygulama çıktısı Windows PowerShell Copyright (C) Microsoft Corporation. All rights reserved. PS C:\Users\Administrator> Invoke-WebRequest "http://www.emreozanmemis.com" -OutFile "file" -PassThru | Select-Object -E xpandProperty Content <!DOCTYPE html> <html lang="tr" prefix="og: http://ogp.me/ns#"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" /> <link rel="profile" href="http://gmpg.org/xfn/11"> <title>Emre Ozan Memis - Cloud and Datacenter Management</title> <style type="text/css"> body .primary-background, body button:hover, body button:focus, body input[type="button"]:hover, body input[type="reset"]:hover, body input[type="reset"]:focus, body input[type="submit"]:hover, body input[type="submit"]:focus, body .widget .social-widget-menu ul li, body .comments-area .comment-list .reply, body .slide-categories a:hover, body .slide-categories a:focus, body .widget .social-widget-menu ul li:hover a:before, body .widget .social-widget-menu ul li:focus a:before, body .ham, body .ham:before, body .ham:after, body .btn-load-more { background: #33363b; } body .secondary-background, body .wp-block-quote, body button, body input[type="button"], body input[type="reset"], body input[type="submit"], body .widget.widget_minimal_grid_tab_posts_widget ul.nav-tabs li.active a, body .widget.widget_minimal_grid_tab_posts_widget ul.nav-tabs > li > a:focus, body .widget.widget_minimal_grid_tab_posts_widget ul.nav-tabs > li > a:hover, body .author-info .author-social > a:hover, body .author-info .author-social > a:focus, body .widget .social-widget-menu ul li a:before, body .widget .social-widget-menu ul li:hover, body .widget .social-widget-menu ul li:focus, body .moretag, body .moretag,1.6KViews5likes0CommentsPowerShell ile Azure üzerinde RHEL VM olusturma (tr-TR)
Sabah ofisinize geldiniz ve x bir proje için acil VM ihtiyacı olduğu iş emri ile karşı karşıya kaldınız. Tüm bunlar için Azure portalına gir tek tek opsiyonları seç VM oluştur gibi süreçlerle uğraşmamak için siz kahvenizi hazırlarken VM kurulumu tamamlanmış olacak bir konudan bahsetmek istiyorum. Windows PowerShell üzerindne Azure portalınıza bağlantı sağlayıp aşağıdaki komut ile yeni bir kaynak grubu oluşturup içinde yeni bir sanal network ve RHEL kurulumunu 2-3 dakika içinde tamamlayabilirsiniz. New-AzResourceGroup -Name AzureRG -Location westus $gatewaysubnet = New-AzVirtualNetworkSubnetConfig -Name PSGatewaySubnet -AddressPrefix "10.102.100.0/27" $virtualNetwork = New-AzVirtualNetwork -Name PSAzureBCVnet -ResourceGroupName PSAzureBootCampRG -Location westus -AddressPrefix "10.102.100.0/24" -Subnet $gatewaysubnet Add-AzVirtualNetworkSubnetConfig -Name PSDMZSubnet -VirtualNetwork $virtualNetwork -AddressPrefix "10.102.100.96/27" $virtualNetwork | Set-AzVirtualNetwork $resourceGroup = "AzureRG" $location = "westus" $vmName = "PS-rhel2-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 "RHEL" -Size "Standard_D2_v3" -VirtualNetworkName "PSAzureBCVnet" -SubnetName "PSDMZSubnet" -Credential $cred -OpenPorts 22 Komutlar bütününü kendinize yada projelerinize göre özelleştirip kütüphanenizde bulundurmanız, bu tip durumlarda siz başka bir işiniz ile ilgilenirken size zaman kazandıracak ve işlerinizi kolaylaştıracaktır. Size ise 22 portundan SSH yapıp suncunun keyifine varmak kalır.1KViews5likes0CommentsCreating a website to display Powershell Script Output
Hi all, I have a quick query, that I'm hoping someone might be able to help me with. I run a number of powershell scripts weekly (Inactive accounts, DA memebers, etc) and the output of each script is emailed to my IT colleagues in either EXCEL or html format. I want to try and create a website, where the output of all these scripts are displayed on one or more pages. Where should I start with this? and how can I integrate powershell into HTML? Should i be looking at ASP.NET? Thanks BrendanSolved14KViews2likes3CommentsKeeping PowerShell up-to-date via WSUS.
Hi, folks. This is a quick one to let any fellow hybrid operators know that PowerShell (as distinct from Windows PowerShell) can be kept up-to-date via WSUS these days. Product and Classifications You can find the PowerShell products listed as shown below, while within the Classifications tab, you want to have the "Updates" category checked. After WSUS synchronisation You'll see it's now aware of the various 7.x branches. After client synchronisation to WSUS You'll see the various updates pending approval for deployment. (Yes, my PowerShell's very old now!) A nice little win for the keeping the small things in (my) life current for zero extra effort. Cheers, Lain445Views2likes0CommentsStore password in Windows credential manager and use it in Powershell
On the #ESPC16 in Vienna someone is showing a way to store credentials in the Windows credential manager and then use is in Powershell to connect to Exchange / SharePoint / Azure… online. It was a very simple and I will use it for some scheduled tasks. But i don’t remember how he does it and I didn’t find such a good and simple way in the net. Anyone has it also seen or use it before?Solved79KViews2likes8CommentsPowerShell ile Active Directory de Olusturulan Kullanıcı Sayısı ve Detay Raporu (tr-TR)
Active Directory Domain Services kullanan yapılarınız için mevcut yapınızda bir SIEM sistemi kullanmıyorsanız kendi raprolarınızı PowerShell temelinde oluşturulan komut bütünleri yada scriptlerle iş süreçlerinizi raporlayabilirsiniz. Hatta ilgili komutlar için görevler oluşturup raporları düzenli olarak çekebilirsiniz. Eğer bu makaleyi arama motorlarında yaptığınız taramalar sonucu bulduysanız işinizi çözecek bir yazı olabilir. Bu makalenin temel amacı AD DS üzerine eklediğiniz yeni kullanıcıları ve detaylarına ulaşmak için hazırlanmıştır. Temel komutumuz "Get-ADUser" komuta ait syntax alt yapısının pratik kullanımı için aşağıdaki adımlar amacınıza ulaştıracaktır. İlk olarak AD DS yapımızda kaç kullanıcı var onu öğrenelim. (get-aduser -filter *).count Bu komutumuz çıktısı aşağıdaki gibi oalcaktır. PS C:\Users\emreozanmemis> (get-aduser -filter *).count 6 AD DS üzerinde 6 adet kullanıcımız olduğunu görüntülüyorum. Biraz daha detay ihtiyacınzı var ise mesala kullanıcının aktiflik durumunu görüntülemek istersek filter olarak enabled opsiyonunu kullanalım. Get-ADUser -Filter * | fl name,enabled Komut Çıktısı: PS C:\Users\emreozanmemis> Get-ADUser -Filter * | fl name,enabled name : emreozanmemis enabled : True name : Guest enabled : False name : krbtgt enabled : False name : test enabled : False name : testemre enabled : True name : test2 enabled : True Çıktımıza göre 3 kullanıcımız aktif, 3 kullanıcımız ise aktif değil şeklinde görüntülüyorum. Bu tabi sizin AD DS yapınıza göre kişi sayısına göre değişiklik gösterecektir. Komutumuzu biraz daha ileriye taşıyalım ve bu çıktırıyı 30 gün ile sınırlıyalım. Örneğin 30 gün geriye dönük oluşturulan kullanıcıların listesini çekelim. Bunu niçin sadece bir zaman değişkeni tanımlayıp bu değişkene geriye dönük 30 gün şeklinde bir düzenleme yapıyorum. Zaman değişkeni tanımlaması için aşağıdaki şekilde bir komut düzenliyorum. $When = ((Get-Date).AddDays(-30)).Date Bu değişkeni şimdi "Get-ADUser" komutumuz ile birleştirelim. Komut düzenimiz aşağıdaki şekilde hazır. $When = ((Get-Date).AddDays(-30)).Date Get-ADUser -Filter {whenCreated -ge $When} -Properties whenCreated Komut Çıktısı: PS C:\Users\emreozanmemis> Get-ADUser -Filter {whenCreated -ge $When} -Properties whenCreated DistinguishedName : CN=test2,CN=Users,DC=1web1medya,DC=com Enabled : True GivenName : test2 Name : test2 ObjectClass : user ObjectGUID : a3853bd3-a800-40cf-b7aa-8537c78e62b4 SamAccountName : test2 SID : S-1-5-21-1346884540-3007984453-3019941278-1112 Surname : UserPrincipalName : test2@1web1medya.com whenCreated : 11/29/2021 7:11:08 AM 30 gün içinde hangi kullancılar açılmış, hangi tarihde oluşturulmuş, SAM bilgisi gibi özet bilgiyi görüntülüyoruz. AD DS yöneticileri için elinde olması gereken bir komut bütünü olduğunu düşünüyorum. Keyifli denemeler.4.1KViews2likes0CommentsPowerShell in BASH for Windows 10
So, you have a Windows 10 Pro (or higher) but somehow don't have a way to build a linux virtual machine. In windows 10 (build 14393) you can install the Ubuntu Linux subsytem Bash in your machine. Currently, if you install PowerShell Open Source in Bash, it won't work. But there's a workaround you can use to make it functional enough to create and run scripts and, at the same time learn about Linux, Check my blog post on it: http://www.maxtblog.com/2016/10/running-powershell-in-windows-10-bash-workaround/1.7KViews2likes0CommentsAbout PowerShell Open Source and the editor of choice!
Just before the "Windows PowerShell" section became available I posted some information that me be on interest under "Windows Server PowerShell" section. Go ahead and check it out at: https://techcommunity.microsoft.com/t5/Windows-Server-PowerShell/PowerShell-Open-Source-and-Editor-of-Choice/m-p/15287#M131.9KViews2likes4CommentsSharepoint online management module reference broken in azure
I have a azure web job in C# where i am trying to connect to SPO through connect-sposervice. I have copied the complete Sharepoint online management shell folder from my local into my project and uploaded but still i get the error in web job D:\home\site\wwwroot\app_data\jobs\triggered\siteproj Unhandled Exception: System.Management.Automation.CmdletInvocationException: The type initializer for 'Microsoft.Online.SharePoint.PowerShell.Resources.StringResourceManager' threw an exception. ---> System.TypeInitializationException: The type initializer for 'Microsoft.Online.SharePoint.PowerShell.Resources.StringResourceManager' threw an exception. ---> System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Online.SharePoint.PowerShell.ResourceManager.Intl, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' or one of its dependencies. The system cannot find the file specified. at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) at System.Reflection.Assembly.Load(AssemblyName assemblyRef) at Microsoft.Online.SharePoint.PowerShell.Resources.StringResourceManager..cctor() --- End of inner exception stack trace --- at Microsoft.Online.SharePoint.PowerShell.Resources.StringResourceManager.GetResourceString(String resourceId, Object[] args) at Microsoft.Online.SharePoint.PowerShell.GetSite.ProcessRecord() at System.Management.Automation.Cmdlet.DoProcessRecord() at System.Management.Automation.CommandProcessor.ProcessRecord() --- End of inner exception stack trace --- at System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input) can anyone help or tell a better way to run powershell to SPOnline commandlets from Azure web job. Or is it Powershell is not for Azure ? Thanks4.8KViews1like9Comments