This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Run the below script to create new role "Virtual Machine Status" which allows the user to just view the Virtual Machine | |
#The most easiest way to get started is by checking the permissions to other role and modifying it as required | |
Get-AzureRmRoleDefinition -Name "Virtual Machine User Login" | |
(Get-AzureRmRoleDefinition -Name "Virtual Machine User Login").actions # list the actions that is possible with this role | |
$role= Get-AzureRmRoleDefinition -Name "Virtual Machine User Login" # copy the role to a variable | |
$role #shows the same output as line#3 | |
#assign custom values to the new role that needs to be created |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Install-Module -Name ExchangeOnlineManagement | |
Connect-ExchangeOnline | |
$upn=Read-Host "Enter the email address the mailbox to be converted to shared mailbox" | |
$manager=Read-Host "Enter the email address of the MANAGER" | |
$access=Read-Host "Does manager need access to old emails? Y for yes and N for No" | |
Set-Mailbox -Identity $upn -Type Shared | |
if ($access -eq 'y') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Get-WmiObject -ComputerName DESKTOP1 -Class Win32_ComputerSystem | Select-Object UserName | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Disable-IEESC { | |
$AdminKey = "HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A7-37EF-4b3f-8CFC-4F3A74704073}" | |
$UserKey = "HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A8-37EF-4b3f-8CFC-4F3A74704073}" | |
Set-ItemProperty -Path $AdminKey -Name "IsInstalled" -Value 0 | |
Set-ItemProperty -Path $UserKey -Name "IsInstalled" -Value 0 | |
Stop-Process -Name Explorer | |
Write-Host "IE Enhanced Security Configuration (ESC) has been disabled." -ForegroundColor Green | |
} | |
Disable-IEESC |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Get all active computers as seeb by AD in last 50 days: | |
$Date = (Get-Date).AddDays(-49) | |
Get-ADComputer -Filter {LastLogonDate -gt $Date} | Select distinguishedName | |
#Get all computers from AD where OS version includes "server": | |
Get-ADComputer -Filter 'operatingsystem -like "*server*" -and enabled -eq "true"' ` | |
-Properties Name,Operatingsystem,OperatingSystemVersion,IPv4Address | | |
Sort-Object -Property Operatingsystem | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#sometimes if the file has been opened in Read+Write mode by excel, a temporary file will be created in the same directory starting with ~$filename.xlsx | |
#delete that temporary file which is in edit mode | |
Get-childitem -path C:\sharefolderpath | |
remove-item -path C:\sharefolderpath\~$File.xlsx | |
#check if the actual file is locked - This will also display the username and client IP along with fileID and sessionID | |
Get-SmbOpenFile | Where-Object -Property sharerelativepath -match "filename.XLSX" | fl |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Find computers added to domain before 30 days | |
$limit = (get-date).adddays(-30) | |
$computers = get-adcomputer -Properties whencreated -Filter {whencreated -lt $limit} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Get folder statistics and check if mailbox is full. If in place archive is enabled, mailbox size in exchange admin centre and outlook | |
#is not correct. This command will show the stats | |
Get-MailboxFolderStatistics -Identity upn@domain.com -IncludeAnalysis -FolderScope RecoverableItems | Format-Table Name,ItemsInFolder,FolderSize,*Subject* | |
# grant mailbox access without automapping in outlook | |
# mailbox id2 is the user who will get access to the mailbox id1 | |
Add-MailboxPermission -Identity <Mailbox ID1> -User <Mailbox ID2> -AccessRights FullAccess -AutoMapping:$false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Problem - windows client shows wrong time | |
#tried to adjust date/time > change date and time > Throws access denied error | |
#found the below commands to fix this: | |
net stop w32time | |
w32tm /unregister | |
w32tm /register | |
net start w32time | |
# Windows time service missing in services so the first command failed |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#variables | |
$storageAccountName = 'storageacc' | |
$sasToken = 'sastoken' | |
$dateTime = get-date | |
# creating new context and define table | |
$storageCtx = New-AzStorageContext -StorageAccountName $storageAccountName -SasToken $sasToken | |
$tablename = (Get-AzStorageTable -Name $tableName -Context $storageCtx).Cloudtable | |
# setting partition key |
OlderNewer