in the powershell file (nulls) also check the filters etc in the query

select o.OrganisationID OrganizationId, o.FullName OrganizationName, mg.GalleryName, m.Name+'.jpg' as MediaName, m.WhenCreated
	from RptGetOrganisationHierarchy(1118, 1, '', '', 1, null) h
	inner join Organisation o
		on o.OrganisationID = h.OrganisationID
	inner join CmsSite cs
		on cs.CmsSiteID = o.CmsSiteID
	inner join CmsPage cp
		on cp.CmsSiteID = cs.CmsSiteID
	inner join PageMediaGallery pmg
		on pmg.PageID = cp.CmsPageID
	inner join MediaGallery mg
		on mg.MediaGalleryID = pmg.MediaGalleryID
	inner join MediaGalleryMedia mgm
		on mgm.MediaGalleryID = mg.MediaGalleryID
	inner join Media m
		on m.MediaID = mgm.MediaID
	where	cp.CmsPageTypeID = 16
			and mg.IsVisible = 1
			and m.WhenCreated >= '2009-01-01'
				and OriginalFileName IS NULL
				
	the is nulls are coming in without the .jpg so we need to run version 1 
	
	So solution is change the file path in the call of the PS script to Images rather than files.  
	
	Also if there are images without .jpg on the end you need ot manally get them and edit like this 
	
	SELECT        TOP (200) MediaID, Caption, Name, WhenCreated, ContentID, OriginalFileName, CreatedByPersonID, CreatedByOrganisationID, ContentType, ContentLength, Title, MediaTypeID, OriginalID, EncoderStatus, 
                         EncoderMessage, EncoderServiceID
FROM            Media
WHERE        (OriginalID IN (3809, 3810, 3811, 3812, 3813, 6828, 6829, 6830, 3814, 3815, 3816, 3817, 3818, 3819))

you could do a find and edi tautomatically but for this many i did manually.


.\zip-galleriesnulls.ps1 D:\zip\zips\ D:\Web\AllTeams-NZ-Prod\Upload\UserMedia\Image\ 1118 172.17.5.66 AllTeamsProduction at "Dread Pirate Roberts!"