# Powershell running function one time

**URL:** <https://forums.powershell.org/t/powershell-running-function-one-time/14406>\
**Category:** PowerShell Help\
**Created:** [May 21, 2020, 3:54pm UTC](https://forums.powershell.org/t/powershell-running-function-one-time/14406 "2020-05-21T15:54:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![peterobles](https://avatars.discourse-cdn.com/v4/letter/p/7ba0ec/32.png) [@peterobles](https://forums.powershell.org/u/peterobles)\
**Post date:** [May 21, 2020, 3:54pm UTC](https://forums.powershell.org/t/powershell-running-function-one-time/14406/1 "2020-05-21T15:54:08Z")

</div>

Hi, I have a small script that goes and check for new rss feed every 1 minute, and the function goes to sleep for another minute. How can I make the function not to keep downloading the same title, unless there is a new topic.

$webclient = new-object System.Net.WebClient  
$url=“[https://something](https://something)”

## Get the web page into a single string

$data = [xml](invoke-webrequest $url).Content  
$Time = Get-Date -format g  
$LastBuiltDate = ($data.rss.channel.LastBuildDate).split(‘’)[4]  
$TimeDiff = New-TimeSpan -Start $LastBuiltDate -End $Time  
if($TimeDiff.minutes -lt 1){  
$items = ($data.rss.channel.item | select title,Description,link, @{LABEL=“Published”;EXPRESSION={[datetime]$\_.pubdate}}|sort-object Published)  
foreach ($msg in $items){  
$titlen = $msg.title -replace ‘\<br ?/?\>’,[System.Environment]::NewLine -replace ‘\<[^\>]+\>’  
$Published = $msg.Published  
$commentsPlain = $msg.Description.InnerText -replace ‘\<br ?/?\>’,[System.Environment]::NewLine -replace ‘\<[^\>]+\>’  
$weblinks = $msg.link.innertext  
}

}

---

<div class="post-metadata">

**Author:** ![rob-simmers](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/rob-simmers/32/1010_2.png) [@rob-simmers](https://forums.powershell.org/u/rob-simmers)\
**Post date:** [May 22, 2020, 3:28pm UTC](https://forums.powershell.org/t/powershell-running-function-one-time/14406/2 "2020-05-22T15:28:40Z")

</div>

The RSS feed API would need to have filters that could leveraged (e.g. Date) to only return items that are newer than the last request. If there is not filter functionality, then you would have to download the results and use Compare-Object to determine what doesn’t currently exist in the stored data set.

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:30pm UTC](https://forums.powershell.org/t/powershell-running-function-one-time/14406/3 "2024-05-16T20:30:36Z")

</div>


