Lapas

trešdiena, 2017. gada 4. janvāris

Change Office 365 sign-in name for AD synced user

To change Office 365 sign-in (Principal) name for user synced with Onsite AD:
  1. Start PowerShell
  2. Make sure the Microsoft Online module is loaded
  3. Execute the following command:
set-msoluserprincipalname -newuserprincipalname newuser@emailaddress.com -userprincipalname user@emailaddress.com.

Source: msonlinehelpdesk.zendesk.com

ceturtdiena, 2016. gada 17. novembris

Copy data to other location and retain permissions

@echo off

SET SRC="\\server\share"
SET DST="C:\WHERE YOU WANT FILES TO GO"
SET LOG="C:\Robocopy.log"

ROBOCOPY %SRC% %DST% /E /ZB /MIR /SEC /SECFIX /COPYALL /R:1 /W:1 /V /TEE /LOG:%LOG%
@if errorlevel 16 echo ***ERROR *** & goto END
@if errorlevel 8  echo **FAILED COPY ** & goto END
@if errorlevel 4  echo *MISMATCHES *      & goto END
@if errorlevel 2  echo EXTRA FILES       & goto END
@if errorlevel 1  echo --Copy Successful--  & goto END
@if errorlevel 0  echo --Copy Successful--  & goto END
goto END

:END

PAUSE


Here's what the switches mean:
  • SRC:: Source Directory (drive:\path or \\server\share\path).
  • DST:: Destination Dir  (drive:\path or \\server\share\path).
  • /E :: copy subdirectories, including Empty ones.
  • /ZB :: use restartable mode; if access denied use Backup mode.
  • /MIR :: Mirrors a directory tree.
  • /SEC :: Copies files with security
  • /SECFIX ::Fixes file security on all files, even skipped ones.
  • /COPYALL :: COPY ALL file info (equivalent to /COPY:DATSOU).  Copies the Data, Attributes, Timestamps, Owner, Permissions and Auditing info
  • /R:n :: number of Retries on failed copies: default is 1 million but I set this to only retry once.
  • /W:n :: Wait time between retries: default is 30 seconds but I set this to 1 second.
  • /V :: produce Verbose output, showing skipped files.
  • /TEE :: output to console window, as well as the log file.
  • /LOG:file :: output status to LOG file (overwrite existing log).
Source: community.spiceworks.com

ceturtdiena, 2016. gada 10. novembris

Clear session on FortiGate

1) Clear filter:
diagnose sys session filter clear

2) Add new filter:
diagnose sys session filter src 192.168.1.110
diagnose sys session filter dport 80
diagnose sys session filter dst 192.168.0.1


3) Check applied filter:
diagnose sys session filter

4) Remove filtered session:
diagnose sys session clear

Source: forum.fortinet.com

trešdiena, 2016. gada 26. oktobris

Ping to file with timestamp

Create batch file:
@echo: off 
set host=192.168.1.1
set logfile=Ping.txt
ping -l 1000 -t %host%|cmd /q /v /c "(pause&pause)>nul & for /l %%a in () do (set /p "data=" && echo(!time! !data!)&ping -n 2 %host%>nul" >> %logfile%


To test from command line use %a instead of %%a

Output:
9:21:50.24 Pinging 192.168.1.1 with 1000 bytes of data:
 9:21:51.29 Reply from 192.168.1.1: bytes=1000 time=43ms TTL=61


Source: stackoverflow.com

otrdiena, 2016. gada 6. septembris

Change Office 365 resource calendar default permitions

If you want to set that everyone can see who booked the resource - you must change default permissions on resource calendar.
Connect Exchange Online with PowerShell.

See permissions on resource calendar:
Get-MailboxFolderPermission -Identity resource@mail.com:\Calendar

FolderName  User       AccessRights
----------  ----       ------------
Calendar    Default    {AvailabilityOnly}
Calendar    Anonymous  {None}


Set permissions on resource calendar:
Set-MailboxFolderPermission -Identity resource@mail.com:\Calendar -User Default -AccessRights Reviewer

FolderName User     AccessRights
---------- ----     ------------
Calendar   Default  {Reviewer}
Calendar   Anonymous {None}


Resource: exchangeserverpro.com

trešdiena, 2016. gada 20. jūlijs

Get list of Hyper-V VM disks

Run in PowerShell: Get-VMHardDiskDrive | Select-Object -Property VMName, VMId, ComputerName, ControllerType, ControllerNumber, ControllerLocation, Path | Sort-Object -Property VMName | Out-GridView -Title "Virtual Disks"

Enter VM name or * to get all.