我正在使用PowerShell自动部署网站,最近发现了无法使用PS设置的AppPool设置。或者至少我没有找到如何做到这一点。
$appPool = $serverManager.ApplicationPools.Add($sitename)...
我需要将“Private Memory Limit”设置为某个值,但看起来 ApplicationPool 或 ApplicationPoolRecycling 对象中没有此类属性。
anybode是否知道此问题的解决方法?
答案 0 :(得分:8)
此脚本使用Get-Webconfiguration和Set-WebConfiguration获取所有应用池的私有内存值。您可以单独设置每个或设置应用程序池默认值以继承它们。我已经注释掉实际完成该组的那一行。
import-module webadministration
$applicationPoolsPath = "/system.applicationHost/applicationPools"
$applicationPools = Get-WebConfiguration $applicationPoolsPath
foreach ($appPool in $applicationPools.Collection)
{
$appPoolPath = "$applicationPoolsPath/add[@name='$($appPool.Name)']"
Get-WebConfiguration "$appPoolPath/recycling/periodicRestart/@privateMemory"
# Set-WebConfiguration "$appPoolPath/recycling/periodicRestart/@privateMemory" -Value 1000
}
答案 1 :(得分:3)
我正在添加答案,因为我在使用现有内容时遇到了麻烦。
public class NotificationActivity extends IntentService {
public NotificationActivity() {
super("NotificationActivity");
}
@SuppressWarnings("deprecation")
@Override
protected void onHandleIntent(Intent intent) {
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
try {
URL csvURL = new URL("http://example.com/example.csv");
BufferedReader in = new BufferedReader(new InputStreamReader(csvURL.openStream()));
CSVReader reader = new CSVReader(in, ',', '\'', 1);
String [] nextLine;
while ((nextLine = reader.readNext()) != null) {
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this);
mBuilder.setSmallIcon(R.drawable.ic_launcher);
mBuilder.setContentTitle("Title");
mBuilder.setContentText(nextLine[4] + nextLine[13]);
mBuilder.setAutoCancel(true);
NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
if (Build.VERSION.SDK_INT < 16) {
mNotificationManager.notify(0, mBuilder.getNotification());
} else {
mNotificationManager.notify(0, mBuilder.build());
}
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
stopSelf();
}
@Override
public void onDestroy() {
// I want to restart this service again in 30 mins
AlarmManager alarm = (AlarmManager)getSystemService(ALARM_SERVICE);
alarm.set(
alarm.RTC_WAKEUP,
System.currentTimeMillis() + (1000 * 60 * 30),
PendingIntent.getService(this, 0, new Intent(this, NotificationActivity.class), 0)
);
}
}
答案 2 :(得分:0)
您的回复帮助我为WSUS服务器遇到的问题提供了解决方案。我知道是WsusPool
的应用程序池大小给我带来了问题,因此我制作了以下PS脚本并将其应用于我的OU
服务器的根WSUS
( 3)我遇到连接错误,我对Reset Server Node
的选择没有帮助。事件查看器具有事件ID 12002、12012、12032、12022、12042、12052和12072。
Set-WebConfiguration "/system.applicationHost/applicationPools/add[@name='WsusPool']/recycling/periodicRestart/@privateMemory" -Value 0