OK, just want to tell that it is not necessary to wait this long time. If you try to get Resource ID by WMI you get it immediately:
$ComputerName = "testPC"
$SCCMServer = "sccmServer"
$SiteCode = "DE0"
$Collection = "Windows 10 x64"
$Res = Get-WmiObject -Namespace "Root\SMS\Site_$SiteCode" -ComputerName "$SCCMServer" -Class SMS_R_SYSTEM -Filter "Name = '$ComputerName'"
Add-CMDeviceCollectionDirectMembershipRule -CollectionName "$Collection" -ResourceId $Res.ResourceID