Kayıtlar

PowerShell etiketine sahip yayınlar gösteriliyor

Office 365–Change the password expiration policy

Resim
The default password expiration policy of  Office 365  is set to 90 days. That means that users have to change their password every 90 days. I think basically this is a good and secure policy but on the other side, it can be annoying and maybe your company has an other security policy or for some other reason you have to deactivate/change this. We can change this setting through PowerShell with the Microsoft Online PowerShell Module. First connect to Office 365  via PowerShell more on this here . Consider, you need administration privileges to change account settings for other users.. To get a list of the Microsoft Online Office 365 users: Get-MsolUser To get the details for a user: Get-MsolUser -UserPrincipalName  user.name@domain.xy Now you can use the following cmdlet to change the password policy for the password to never expire.. Set-MsolUser –UserPrincipalName  user@contoso.com  –PasswordNeverExpires $true and if you’re a freak like me  Get-MsolUser | Se

Office 365–Connect to MsOnline using PowerShell

Resim
The administration and configuration of Office 365 can done using PowerShell. To connect to the Office 365, you need the appropriate modules installed. These modules are available from Microsoft website. This article describes how to connect to Office 365 provider. Install the Microsoft Online Services Sign-In Assistant 32-bit 64-bit Install the Microsoft Online Services Module for Windows PowerShell 32-bit 64-bit Open PowerShell and import the MsOnline Module or use the desktop shortcut which was created by the installer. Import—Module MsOnline Connect to your Microsoft Office 365 account Connect-MsolService Use your Office 365 LiveID to login (for example username@company.onmicrosoft.com ) Now you can start working with Windows Powershell in your Office 365 account, if you need some more help about the available Powershell cmdlets you can list them with Get-Command –Module MsOnline have phun!

PowerShell: Get SID from AD (Active Directory) User / Group using PowerShell

Resim
To get the SID of an AD Object (User, Group, whatever) quickly, i recommend using PowerShell. When trying to get the SID using ADUC (Active Directory User and Computer Snap-in), you can not copy/paste the SID as a string since it is stored in a binary format. Now, to get the SID (Security Identifier) for a specific (AD) Active Directory Object using PowerShell use: $AdObj = New-Object System.Security.Principal.NTAccount ( & quot;ObjectName & quot; ) $strSID = $AdObj .Translate ( [ System.Security.Principal.SecurityIdentifier ] ) $strSID .Value

Test-Run a PowerShell or Exchange Management Shell Command

Exchange Management Shell/PowerShell commands allow the addition of the “-whatif” parameter, which will test your command without actually executing it. Example :  Set-Mailbox -Identity testmailbox -DisplayName “Test User”  -whatif

File Content Search in PowerShell

There is a way to use Powershell to search the contents of a file.  This method will not use the Windows index so it will be slow, but it does work. get-childitem c:users -filter *.txt -recurse | select-string -list -pattern “yourtext” | foreach {$_.Path} Explanation get-childitem : Get the children for a container.  In this example the container is a folder on the file system. The first argument is the directory to search (c:users). The –filter switch is used to limit what files to search, in this example it will search files with a txt extension. Process all sub-directories with the –recurse switch. select-string : Find text in strings or files. The –list switch stops the search within the source once the match is found.  In other words it will not waste time looking for other occurrences of the text. The –pattern switch is where you specify the search text.  Regex is permitted. foreach :  Iterate the resulting files. $_.Path :  Output the full path for the file

File Name Search in PowerShell

Here a simple but effective command to retrieve a list of all files in a directory tree containing a specific text in the file name. dir c:users -r -i “*yourtext*” Explanation The first argument is the directory to search (c:users). Process all sub-directories with the –r switch. The -i switch is used to specify which file names to search for, in this case all files containing yourtext