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
#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
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-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
#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
#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 |
NewerOlder