Question : RMS report, filter Last Month

Is there a way in Retail Management System reports to have the filter date automatically show Last Month dates when opening a report?

I know I can specify Last Month in the drop down list upon opening, but is there a way so the dates of "Last Month" (e.g. right now it would be May 1-31) will be automatically put in as a filter? The .qrp file is editable and I can filter by <Today> and <MonthStart>, but I cannot get anything to work that has to do with Last month...

Any ideas?

Answer : RMS report, filter Last Month

Found the code. Here are some of the key pieces of the code/logic.

Again, for every webapplication, I get every site collection. The code starts on a given site collection.

Get the site collection user list.
For each user, check if user exist in AD via LoginName (samAccountName). If user exist skip (migrateuser not needed). If user doesn't exist, get the user's SID and look up AD based on SID.
If found, get the new login name and generate migrate user command to the batch file.
Note that the batch file will have multiple repeating lines for the same user across the site collections. I use a powershell sort command to remove the duplicates in the end (GC C:\migrateUsers.txt| Sort | GU > C:\migrateUsers.bat)



1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") > $null
$site = new-object Microsoft.SharePoint.SPSite($SiteCollectionURL)
$web = $site.openweb()

$siteCollUsers = $web.SiteUsers

foreach($MyUser in $siteCollUsers)
{
	if(($MyUser.LoginName.ToLower() -ne "sharepoint\system") -and ($MyUser.LoginName.ToLower() -ne "nt authority\authenticated users") -and ($MyUser.LoginName.ToLower() -ne "nt authority\local service"))
	{
		$UserName = $MyUser.LoginName.ToLower()
		$UserNameSplit = $UserName.split("\")
		#Write-Host "User Login: ", $MyUser.LoginName, "SID: ", $MyUser.Sid

		$returncheck = Check_User_In_ActiveDirectory $UserNameSplit[1] $mydomaincnx 
		if($returncheck -eq $False)
		{

			$nameFromSID = ConvertTo-Name $MyUser.Sid
			if ($nameFromSID -ne "User Not Found")
			{
				$command = "stsadm.exe -o migrateuser -oldlogin " + $MyUser.LoginNAme + " -newlogin " + $nameFromSID + " -ignoresidhistory"
				Write-output $command | out-file C:\migrateUsers.txt -append
			}


		}
	}
}

$web.Dispose()
$site.Dispose()

function ConvertTo-Name ($SID) 
{
   trap 
   {
      "User Not Found"; continue
   }
   ((new-object security.principal.securityidentifier $SID).translate([security.principal.ntaccount])).Value
}

function Check_User_In_ActiveDirectory([string]$LoginName, [string]$domaincnx)
{
	$returnValue = $false
	#Filter on User which exists and activated
	$strFilter = "(&(|(objectCategory=user)(objectCategory=group))(samAccountName=$LoginName))"
	$objDomain = New-Object System.DirectoryServices.DirectoryEntry($domaincnx)

	$objSearcher = New-Object System.DirectoryServices.DirectorySearcher
	$objSearcher.SearchRoot = $objDomain
	$objSearcher.PageSize = 1000
	$objSearcher.Filter = $strFilter
	$objSearcher.SearchScope = "Subtree"

	#$objSearcher.PropertiesToLoad.Add("name")

	$colResults = $objSearcher.FindAll()

	if($colResults.Count -gt 0)
	{
		#Write-Host "Account exists and Active: ", $LoginName
		$returnValue = $true
	}
	return $returnValue
}
Random Solutions  
 
programming4us programming4us